/**
  * @dataProvider iterationProvider
  *
  * @param array $data
  */
 public function testIteration(array $data)
 {
     // should called once even multiple iteration
     $this->iterator->expects($this->once())->method('getData')->will($this->returnValue($data));
     $expectedKeys = array_keys($data);
     $expectedValues = array_values($data);
     foreach (range(1, 2) as $numberOfIteration) {
         $keys = $values = [];
         foreach ($this->iterator as $key => $value) {
             $keys[] = $key;
             $values[] = $value;
         }
         $this->assertSame($expectedKeys, $keys, 'Should return correct keys');
         $this->assertSame($expectedValues, $values, 'Should return correct values');
     }
     $this->assertSame($data, iterator_to_array($this->iterator), 'Should return correct data and do not call load');
     $this->assertCount(count($data), $this->iterator);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     return (array) parent::current();
 }