Add 'set' and 'bootstrap' methods to Env/Get/Post
[platal.git] / ut / arrayiteratortest.php
index 06e0455..5a7112e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -26,21 +26,21 @@ class ArrayIteratorTest extends PlTestCase
     public function testSimple()
     {
         $it = PlIteratorUtils::fromArray(array(1, 2, 3, 4));
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(array('keys' => array(0), 'value' => 1), $it->next());
+        $this->assertSame(array('keys' => array(0), 'value' => 1), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(1), 'value' => 2), $it->next());
+        $this->assertSame(array('keys' => array(1), 'value' => 2), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(2), 'value' => 3), $it->next());
+        $this->assertSame(array('keys' => array(2), 'value' => 3), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(3), 'value' => 4), $it->next());
+        $this->assertSame(array('keys' => array(3), 'value' => 4), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -50,21 +50,21 @@ class ArrayIteratorTest extends PlTestCase
     public function testSimpleFlat()
     {
         $it = PlIteratorUtils::fromArray(array(1, 2, 3, 4), 1, true);
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(1, $it->next());
+        $this->assertSame(1, $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(2, $it->next());
+        $this->assertSame(2, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(3, $it->next());
+        $this->assertSame(3, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(4, $it->next());
+        $this->assertSame(4, $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -74,21 +74,21 @@ class ArrayIteratorTest extends PlTestCase
     public function testAssoc()
     {
         $it = PlIteratorUtils::fromArray(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4));
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(array('keys' => array('a'), 'value' => 1), $it->next());
+        $this->assertSame(array('keys' => array('a'), 'value' => 1), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('b'), 'value' => 2), $it->next());
+        $this->assertSame(array('keys' => array('b'), 'value' => 2), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('c'), 'value' => 3), $it->next());
+        $this->assertSame(array('keys' => array('c'), 'value' => 3), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('d'), 'value' => 4), $it->next());
+        $this->assertSame(array('keys' => array('d'), 'value' => 4), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -98,21 +98,21 @@ class ArrayIteratorTest extends PlTestCase
     public function testAssocFlat()
     {
         $it = PlIteratorUtils::fromArray(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4), 1, true);
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(1, $it->next());
+        $this->assertSame(1, $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(2, $it->next());
+        $this->assertSame(2, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(3, $it->next());
+        $this->assertSame(3, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(4, $it->next());
+        $this->assertSame(4, $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -122,13 +122,13 @@ class ArrayIteratorTest extends PlTestCase
     public function testDepth()
     {
         $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 1);
-        $this->assertEquals(2, $it->total());
+        $this->assertSame(2, $it->total());
 
-        $this->assertEquals(array('keys' => array(0), 'value' => array(1, 2)), $it->next());
+        $this->assertSame(array('keys' => array(0), 'value' => array(1, 2)), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(1), 'value' => array(3, 4)), $it->next());
+        $this->assertSame(array('keys' => array(1), 'value' => array(3, 4)), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -136,21 +136,21 @@ class ArrayIteratorTest extends PlTestCase
 
 
         $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 2);
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(array('keys' => array(0, 0), 'value' => 1), $it->next());
+        $this->assertSame(array('keys' => array(0, 0), 'value' => 1), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(0, 1), 'value' => 2), $it->next());
+        $this->assertSame(array('keys' => array(0, 1), 'value' => 2), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(1, 0), 'value' => 3), $it->next());
+        $this->assertSame(array('keys' => array(1, 0), 'value' => 3), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array(1, 1), 'value' => 4), $it->next());
+        $this->assertSame(array('keys' => array(1, 1), 'value' => 4), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -160,13 +160,13 @@ class ArrayIteratorTest extends PlTestCase
     public function testDepthFlat()
     {
         $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 1, true);
-        $this->assertEquals(2, $it->total());
+        $this->assertSame(2, $it->total());
 
-        $this->assertEquals(array(1, 2), $it->next());
+        $this->assertSame(array(1, 2), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array(3, 4), $it->next());
+        $this->assertSame(array(3, 4), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -174,21 +174,21 @@ class ArrayIteratorTest extends PlTestCase
 
 
         $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 2, true);
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(1, $it->next());
+        $this->assertSame(1, $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(2, $it->next());
+        $this->assertSame(2, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(3, $it->next());
+        $this->assertSame(3, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(4, $it->next());
+        $this->assertSame(4, $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -198,13 +198,13 @@ class ArrayIteratorTest extends PlTestCase
     public function testDepthAssoc()
     {
         $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 1);
-        $this->assertEquals(2, $it->total());
+        $this->assertSame(2, $it->total());
 
-        $this->assertEquals(array('keys' => array('a'), 'value' => array('b' => 1, 'c' => 2)), $it->next());
+        $this->assertSame(array('keys' => array('a'), 'value' => array('b' => 1, 'c' => 2)), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('d'), 'value' => array('e' => 3, 'f' => 4)), $it->next());
+        $this->assertSame(array('keys' => array('d'), 'value' => array('e' => 3, 'f' => 4)), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -212,21 +212,21 @@ class ArrayIteratorTest extends PlTestCase
 
 
         $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 2);
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(array('keys' => array('a', 'b'), 'value' => 1), $it->next());
+        $this->assertSame(array('keys' => array('a', 'b'), 'value' => 1), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('a', 'c'), 'value' => 2), $it->next());
+        $this->assertSame(array('keys' => array('a', 'c'), 'value' => 2), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('d', 'e'), 'value' => 3), $it->next());
+        $this->assertSame(array('keys' => array('d', 'e'), 'value' => 3), $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('keys' => array('d', 'f'), 'value' => 4), $it->next());
+        $this->assertSame(array('keys' => array('d', 'f'), 'value' => 4), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -236,13 +236,13 @@ class ArrayIteratorTest extends PlTestCase
     public function testDepthAssocFlat()
     {
         $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 1, true);
-        $this->assertEquals(2, $it->total());
+        $this->assertSame(2, $it->total());
 
-        $this->assertEquals(array('b' => 1, 'c' => 2), $it->next());
+        $this->assertSame(array('b' => 1, 'c' => 2), $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(array('e' => 3, 'f' => 4), $it->next());
+        $this->assertSame(array('e' => 3, 'f' => 4), $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());
 
@@ -250,21 +250,21 @@ class ArrayIteratorTest extends PlTestCase
 
 
         $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 2, true);
-        $this->assertEquals(4, $it->total());
+        $this->assertSame(4, $it->total());
 
-        $this->assertEquals(1, $it->next());
+        $this->assertSame(1, $it->next());
         $this->assertTrue($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(2, $it->next());
+        $this->assertSame(2, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(3, $it->next());
+        $this->assertSame(3, $it->next());
         $this->assertFalse($it->first());
         $this->assertFalse($it->last());
 
-        $this->assertEquals(4, $it->next());
+        $this->assertSame(4, $it->next());
         $this->assertFalse($it->first());
         $this->assertTrue($it->last());