| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function testIterationCallsFetchOncePerStep() |
||
| 22 | { |
||
| 23 | $values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible']; |
||
| 24 | $calls = 0; |
||
| 25 | |||
| 26 | $stmt = $this->createMock(Statement::class); |
||
| 27 | $stmt->expects($this->exactly(10)) |
||
| 28 | ->method('fetch') |
||
| 29 | ->willReturnCallback(function() use ($values, &$calls) { |
||
| 30 | $value = $values[$calls]; |
||
| 31 | $calls++; |
||
| 32 | return $value; |
||
| 33 | }); |
||
| 34 | |||
| 35 | $stmtIterator = new StatementIterator($stmt); |
||
| 36 | foreach ($stmtIterator as $i => $_) { |
||
| 37 | $this->assertEquals($i + 1, $calls); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 |