Exemple #1
0
 /**
  * Tests __debugInfo() or debug() usage
  *
  * @return void
  */
 public function testDebug()
 {
     $items = [1, 2, 3];
     $collection = new Collection($items);
     $result = $collection->__debugInfo();
     $expected = ['count' => 3];
     $this->assertSame($expected, $result);
     // Calling it again will rewind
     $result = $collection->__debugInfo();
     $expected = ['count' => 3];
     $this->assertSame($expected, $result);
     // Make sure it also works with non rewindable iterators
     $iterator = new NoRewindIterator(new ArrayIterator($items));
     $collection = new Collection($iterator);
     $result = $collection->__debugInfo();
     $expected = ['count' => 3];
     $this->assertSame($expected, $result);
     // Calling it again will in this case not rewind
     $result = $collection->__debugInfo();
     $expected = ['count' => 0];
     $this->assertSame($expected, $result);
 }