From e0b8de519a737afa5765a7bda4856c045a8eb984 Mon Sep 17 00:00:00 2001 From: knut <> Date: Wed, 30 May 2007 22:19:15 +0000 Subject: full coverage on TAttributeCollection --- .../unit/Collections/TAttributeCollectionTest.php | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/unit/Collections/TAttributeCollectionTest.php (limited to 'tests/unit/Collections/TAttributeCollectionTest.php') diff --git a/tests/unit/Collections/TAttributeCollectionTest.php b/tests/unit/Collections/TAttributeCollectionTest.php new file mode 100644 index 00000000..afded5f3 --- /dev/null +++ b/tests/unit/Collections/TAttributeCollectionTest.php @@ -0,0 +1,102 @@ +Property = 'value'; + self::assertEquals('value', $collection->Property); + self::assertEquals(true, $collection->canGetProperty('Property')); + } + + public function testCanNotGetUndefinedProperty() { + $collection = new TAttributeCollection(array(), true); + self::assertEquals(false, $collection->canGetProperty('Property')); + try { + $value = $collection->Property; + } catch(TInvalidOperationException $e) { + return; + } + self::fail('An expected TInvalidOperationException was not raised'); + } + + public function testCanSetProperty() { + $collection = new TAttributeCollection(); + $collection->Property = 'value'; + self::assertEquals('value', $collection->itemAt('Property')); + self::assertEquals(true, $collection->canSetProperty('Property')); + } + + public function testCanNotSetPropertyIfReadOnly() { + $collection = new TAttributeCollection(array(), true); + try { + $collection->Property = 'value'; + } catch(TInvalidOperationException $e) { + return; + } + self::fail('An expected TInvalidOperationException was not raised'); + } + + public function testGetCaseSensitive() { + $collection = new TAttributeCollection(); + $collection->setCaseSensitive(false); + self::assertEquals(false, $collection->getCaseSensitive()); + $collection->setCaseSensitive(true); + self::assertEquals(true, $collection->getCaseSensitive()); + } + + public function testSetCaseSensitive() { + $collection = new TAttributeCollection(); + $collection->Property = 'value'; + $collection->setCaseSensitive(false); + self::assertEquals('value', $collection->itemAt('property')); + } + + public function testItemAt() { + $collection = new TAttributeCollection(); + $collection->Property = 'value'; + self::assertEquals('value', $collection->itemAt('Property')); + } + + public function testAdd() { + $collection = new TAttributeCollection(); + $collection->add('Property', 'value'); + self::assertEquals('value', $collection->itemAt('Property')); + } + + public function testRemove() { + $collection = new TAttributeCollection(); + $collection->add('Property', 'value'); + $collection->remove('Property'); + self::assertEquals(0, count($collection)); + } + + public function testContains() { + $collection = new TAttributeCollection(); + self::assertEquals(false, $collection->contains('Property')); + $collection->Property = 'value'; + self::assertEquals(true, $collection->contains('Property')); + } + + public function testHasProperty() { + $collection = new TAttributeCollection(); + self::assertEquals(false, $collection->hasProperty('Property')); + $collection->Property = 'value'; + self::assertEquals(true, $collection->hasProperty('Property')); + } + +} + +?> -- cgit v1.2.3