summaryrefslogtreecommitdiff
path: root/tests/unit/Collections/TMapTest.php
diff options
context:
space:
mode:
authorknut <>2007-05-29 23:10:22 +0000
committerknut <>2007-05-29 23:10:22 +0000
commit0c859c17c7439155d2ed185cb5f1d3977519c002 (patch)
tree79090adfe0de3ef96b39b941152505cd3ec1b88d /tests/unit/Collections/TMapTest.php
parent261b6cb919c3c17ba9105958bb0fbbbbe3d74035 (diff)
full coverage on TList and TMap in System.Collections
Diffstat (limited to 'tests/unit/Collections/TMapTest.php')
-rw-r--r--tests/unit/Collections/TMapTest.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/unit/Collections/TMapTest.php b/tests/unit/Collections/TMapTest.php
index 10e620f5..c6a2172c 100644
--- a/tests/unit/Collections/TMapTest.php
+++ b/tests/unit/Collections/TMapTest.php
@@ -36,6 +36,13 @@ class TMapTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(2,$map2->getCount());
}
+ public function testGetReadOnly() {
+ $map = new TMap(null, true);
+ self::assertEquals(true, $map->getReadOnly(), 'List is not read-only');
+ $map = new TList(null, false);
+ self::assertEquals(false, $map->getReadOnly(), 'List is read-only');
+ }
+
public function testGetCount() {
$this->assertEquals(2,$this->map->getCount());
}
@@ -51,6 +58,16 @@ class TMapTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($this->map->getCount()==3 && $this->map->contains('key3'));
}
+ public function testCanNotAddWhenReadOnly() {
+ $map = new TMap(array(), true);
+ try {
+ $map->add('key', 'value');
+ } catch(TInvalidOperationException $e) {
+ return;
+ }
+ self::fail('An expected TInvalidOperationException was not raised');
+ }
+
public function testRemove()
{
$this->map->remove('key1');
@@ -58,6 +75,16 @@ class TMapTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($this->map->remove('unknown key')===null);
}
+ public function testCanNotRemoveWhenReadOnly() {
+ $map = new TMap(array('key' => 'value'), true);
+ try {
+ $map->remove('key');
+ } catch(TInvalidOperationException $e) {
+ return;
+ }
+ self::fail('An expected TInvalidOperationException was not raised');
+ }
+
public function testClear()
{
$this->map->clear();
@@ -150,6 +177,11 @@ class TMapTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(isset($this->map['key1']));
$this->assertFalse(isset($this->map['unknown key']));
}
+
+ public function testToArray() {
+ $map = new TMap(array('key' => 'value'));
+ self::assertEquals(array('key' => 'value'), $map->toArray());
+ }
}
-?> \ No newline at end of file
+?>