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