getIterator() public method

This method is required by the interface \IteratorAggregate.
public getIterator ( ) : Iterator
return Iterator an iterator for traversing the items in the queue.
Beispiel #1
0
 public function testGetIterator()
 {
     $queue = new TQueue(array(1, 2));
     self::assertInstanceOf('ArrayIterator', $queue->getIterator());
     $n = 0;
     $found = 0;
     foreach ($queue as $index => $item) {
         foreach ($queue as $a => $b) {
         }
         // test of iterator
         $n++;
         if ($index === 0 && $item === 1) {
             $found++;
         }
         if ($index === 1 && $item === 2) {
             $found++;
         }
     }
     self::assertTrue($n == 2 && $found == 2);
 }