summaryrefslogtreecommitdiff
path: root/tests/unit/Collections/TListTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Collections/TListTest.php')
-rw-r--r--tests/unit/Collections/TListTest.php68
1 files changed, 33 insertions, 35 deletions
diff --git a/tests/unit/Collections/TListTest.php b/tests/unit/Collections/TListTest.php
index 349d87ed..9d6950b9 100644
--- a/tests/unit/Collections/TListTest.php
+++ b/tests/unit/Collections/TListTest.php
@@ -8,7 +8,7 @@ class ListItem {
* @package System.Collections
*/
class TListTest extends PHPUnit_Framework_TestCase {
-
+
protected $list;
protected $item1, $item2, $item3, $item4;
@@ -21,7 +21,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
$this->list->add($this->item1);
$this->list->add($this->item2);
}
-
+
public function tearDown() {
$this->list=null;
$this->item1=null;
@@ -29,7 +29,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
$this->item3=null;
$this->item4=null;
}
-
+
public function testConstruct() {
$a=array(1,2,3);
$list=new TList($a);
@@ -37,19 +37,19 @@ class TListTest extends PHPUnit_Framework_TestCase {
$list2=new TList($this->list);
$this->assertEquals(2,$list2->getCount());
}
-
+
public function testGetReadOnly() {
$list = new TList(null, true);
self::assertEquals(true, $list->getReadOnly(), 'List is not read-only');
$list = new TList(null, false);
self::assertEquals(false, $list->getReadOnly(), 'List is read-only');
}
-
+
public function testGetCount() {
$this->assertEquals(2,$this->list->getCount());
$this->assertEquals(2,$this->list->Count);
}
-
+
public function testItemAt() {
$this->assertTrue($this->list->itemAt(0) === $this->item1);
$this->assertTrue($this->list->itemAt(1) === $this->item2);
@@ -59,14 +59,14 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidDataValueException $e) {
}
}
-
+
public function testAdd() {
$this->assertEquals(2,$this->list->add(null));
$this->assertEquals(3,$this->list->add($this->item3));
$this->assertEquals(4,$this->list->getCount());
$this->assertEquals(3,$this->list->indexOf($this->item3));
}
-
+
public function testCanNotAddWhenReadOnly() {
$list = new TList(array(), true);
try {
@@ -75,7 +75,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidOperationException $e) {
}
}
-
+
public function testInsertAt() {
$this->assertNull($this->list->insertAt(0,$this->item3));
$this->assertEquals(3,$this->list->getCount());
@@ -88,7 +88,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidDataValueException $e) {
}
}
-
+
public function testCanNotInsertAtWhenReadOnly() {
$list = new TList(array(), true);
try {
@@ -102,7 +102,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidOperationException $e) {
}
}
-
+
public function testInsertBefore() {
try {
$this->list->insertBefore($this->item4,$this->item3);
@@ -116,7 +116,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(1,$this->list->indexOf($this->item1));
$this->assertEquals(2,$this->list->indexOf($this->item2));
}
-
+
public function testCanNotInsertBeforeWhenReadOnly() {
$list = new TList(array(5), true);
try {
@@ -130,7 +130,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidOperationException $e) {
}
}
-
+
public function testInsertAfter() {
try {
$this->list->insertAfter($this->item4,$this->item3);
@@ -144,7 +144,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(1,$this->list->indexOf($this->item2));
$this->assertEquals(2,$this->list->indexOf($this->item3));
}
-
+
public function testCanNotInsertAfterWhenReadOnly() {
$list = new TList(array(5), true);
try {
@@ -158,7 +158,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidOperationException $e) {
}
}
-
+
public function testRemove() {
$this->assertEquals(0,$this->list->remove($this->item1));
$this->assertEquals(1,$this->list->getCount());
@@ -170,7 +170,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(Exception $e) {
}
}
-
+
public function testCanNotRemoveWhenReadOnly() {
$list = new TList(array(1, 2, 3), true);
try {
@@ -178,7 +178,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
self::fail('An expected TInvalidOperationException was not raised');
} catch(TInvalidOperationException $e) {
}
-
+
$list = new TList(array(1, 2, 3), true);
try {
$list->remove(10);
@@ -186,7 +186,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidOperationException $e) {
}
}
-
+
public function testRemoveAt() {
$this->list->add($this->item3);
$this->assertEquals($this->item2, $this->list->removeAt(1));
@@ -199,7 +199,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidDataValueException $e) {
}
}
-
+
public function testCanNotRemoveAtWhenReadOnly() {
$list = new TList(array(1, 2, 3), true);
try {
@@ -207,7 +207,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
self::fail('An expected TInvalidOperationException was not raised');
} catch(TInvalidOperationException $e) {
}
-
+
$list = new TList(array(1, 2, 3), true);
try {
$list->removeAt(10);
@@ -215,14 +215,14 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidOperationException $e) {
}
}
-
+
public function testClear() {
$this->list->clear();
$this->assertEquals(0,$this->list->getCount());
$this->assertEquals(-1,$this->list->indexOf($this->item1));
$this->assertEquals(-1,$this->list->indexOf($this->item2));
}
-
+
public function testCanNotClearWhenReadOnly() {
$list = new TList(array(1, 2, 3), true);
try {
@@ -232,19 +232,19 @@ class TListTest extends PHPUnit_Framework_TestCase {
}
self::fail('An expected TInvalidOperationException was not raised');
}
-
+
public function testContains() {
$this->assertTrue($this->list->contains($this->item1));
$this->assertTrue($this->list->contains($this->item2));
$this->assertFalse($this->list->contains($this->item3));
}
-
+
public function testIndexOf() {
$this->assertEquals(0,$this->list->indexOf($this->item1));
$this->assertEquals(1,$this->list->indexOf($this->item2));
$this->assertEquals(-1,$this->list->indexOf($this->item3));
}
-
+
public function testCopyFrom() {
$array=array($this->item3,$this->item1);
$this->list->copyFrom($array);
@@ -255,7 +255,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidDataTypeException $e) {
}
}
-
+
public function testMergeWith() {
$array=array($this->item3,$this->item1);
$this->list->mergeWith($array);
@@ -266,12 +266,12 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidDataTypeException $e) {
}
}
-
+
public function testToArray() {
$array=$this->list->toArray();
$this->assertTrue(count($array)==2 && $array[0]===$this->item1 && $array[1]===$this->item2);
}
-
+
public function testArrayRead() {
$this->assertTrue($this->list[0]===$this->item1);
$this->assertTrue($this->list[1]===$this->item2);
@@ -281,7 +281,7 @@ class TListTest extends PHPUnit_Framework_TestCase {
} catch(TInvalidDataValueException $e) {
}
}
-
+
public function testGetIterator() {
$n=0;
$found=0;
@@ -295,25 +295,25 @@ class TListTest extends PHPUnit_Framework_TestCase {
}
$this->assertTrue($n==2 && $found==2);
}
-
+
public function testArrayMisc() {
$this->assertEquals($this->list->Count,count($this->list));
$this->assertTrue(isset($this->list[1]));
$this->assertFalse(isset($this->list[2]));
}
-
+
public function testOffsetSetAdd() {
$list = new TList(array(1, 2, 3));
$list->offsetSet(null, 4);
self::assertEquals(array(1, 2, 3, 4), $list->toArray());
}
-
+
public function testOffsetSetReplace() {
$list = new TList(array(1, 2, 3));
$list->offsetSet(1, 4);
self::assertEquals(array(1, 4, 3), $list->toArray());
}
-
+
public function testOffsetUnset() {
$list = new TList(array(1, 2, 3));
$list->offsetUnset(1);
@@ -321,5 +321,3 @@ class TListTest extends PHPUnit_Framework_TestCase {
}
}
-
-?> \ No newline at end of file