diff options
author | knut <> | 2007-05-30 22:19:15 +0000 |
---|---|---|
committer | knut <> | 2007-05-30 22:19:15 +0000 |
commit | e0b8de519a737afa5765a7bda4856c045a8eb984 (patch) | |
tree | 2a7d8a6e14c276112036efd6b27a8cdc98f7fbb7 | |
parent | bfb9b4c89d76ad2c12e88fb7d70639f76badcdbf (diff) |
full coverage on TAttributeCollection
-rw-r--r-- | .gitattributes | 1 | ||||
-rw-r--r-- | tests/unit/Collections/AllTests.php | 2 | ||||
-rw-r--r-- | tests/unit/Collections/TAttributeCollectionTest.php | 102 |
3 files changed, 105 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes index 850fb4f6..7faee17e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2796,6 +2796,7 @@ tests/unit/AllTests.php -text tests/unit/Caching/TDirectoryCacheDependencyTest.php -text tests/unit/Caching/TFileCacheDependencyTest.php -text tests/unit/Collections/AllTests.php -text +tests/unit/Collections/TAttributeCollectionTest.php -text tests/unit/Collections/TListTest.php -text tests/unit/Collections/TMapTest.php -text tests/unit/Collections/TQueueTest.php -text diff --git a/tests/unit/Collections/AllTests.php b/tests/unit/Collections/AllTests.php index a639a42c..84ac3a9c 100644 --- a/tests/unit/Collections/AllTests.php +++ b/tests/unit/Collections/AllTests.php @@ -9,6 +9,7 @@ require_once 'TListTest.php'; require_once 'TMapTest.php'; require_once 'TQueueTest.php'; require_once 'TStackTest.php'; +require_once 'TAttributeCollectionTest.php'; class Collections_AllTests { public static function main() { @@ -22,6 +23,7 @@ class Collections_AllTests { $suite->addTestSuite('TMapTest'); $suite->addTestSuite('TQueueTest'); $suite->addTestSuite('TStackTest'); + $suite->addTestSuite('TAttributeCollectionTest'); return $suite; } 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 @@ +<?php +require_once dirname(__FILE__).'/../phpunit.php'; + +Prado::using('System.Collections.TAttributeCollection'); + +/** + * @package System.Collections + */ +class TAttributeCollectionTest extends PHPUnit_Framework_TestCase { + + public function setUp() { + } + + public function tearDown() { + } + + public function testCanGetProperty() { + $collection = new TAttributeCollection(); + $collection->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')); + } + +} + +?> |