| Conditions | 1 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function testMapIterator() |
||
| 25 | { |
||
| 26 | $callback = new MockeryCallableMock(); |
||
| 27 | $iterator = new ArrayIterator(['key' => 'value', 'second' => 'monkey', 'third']); |
||
| 28 | |||
| 29 | $mapIterator = new MapIterator($iterator, $callback); |
||
| 30 | |||
| 31 | $callback->shouldBeCalled() |
||
| 32 | ->with('value', 'key', $iterator) |
||
| 33 | ->andReturn('modified'); |
||
| 34 | $callback->shouldBeCalled() |
||
| 35 | ->with('monkey', 'second', $iterator) |
||
| 36 | ->andReturn('fish'); |
||
| 37 | $callback->shouldBeCalled() |
||
| 38 | ->with('third', 0, $iterator) |
||
| 39 | ->andReturn('cake'); |
||
| 40 | |||
| 41 | $results = iterator_to_array($mapIterator, true); |
||
| 42 | |||
| 43 | static::assertEquals( |
||
| 44 | [ |
||
| 45 | 'key' => 'modified', |
||
| 46 | 'second' => 'fish', |
||
| 47 | 'cake', |
||
| 48 | ], |
||
| 49 | $results |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |