Esempio n. 1
0
 /**
  * Tests the whole class.
  */
 public function testIterator()
 {
     $data = range(0, 10);
     $callback = function ($value) {
         return 0 == $value % 2;
     };
     $iterator = new FilterIterator(new \ArrayIterator($data), $callback);
     $expected = array(0 => 0, 2 => 2, 4 => 4, 6 => 6, 8 => 8, 10 => 10);
     $results = array();
     foreach ($iterator as $key => $value) {
         $results[$key] = $value;
     }
     $this->assertSame($expected, $results);
     $this->assertSame($expected, $iterator->toArray());
 }