Skip to content

Commit 4525540

Browse files
committed
Improving code coverage
1 parent 09b4dab commit 4525540

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/EmptyInnerResultIteratorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public function testIterate()
3838
foreach ($iterator as $elem) {
3939
$this->fail('Iterator should be empty');
4040
}
41-
$this->assertTrue(true);
41+
42+
$iterator->next();
43+
$this->assertNull($iterator->current());
44+
$this->assertNull($iterator->key());
4245
}
4346

4447
public function testOffsetGet()

tests/MapIteratorTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,31 @@
2121

2222
namespace TheCodingMachine\TDBM;
2323

24+
use ArrayIterator;
25+
use IteratorAggregate;
2426
use PHPUnit\Framework\TestCase;
2527

2628
class MapIteratorTest extends TestCase
2729
{
30+
public function testIteratorAggregate(): void
31+
{
32+
$mapIterator = new MapIterator(new class implements IteratorAggregate
33+
{
34+
public $property1 = "Public property one";
35+
public $property2 = "Public property two";
36+
public $property3 = "Public property three";
37+
38+
public function getIterator()
39+
{
40+
return new ArrayIterator($this);
41+
}
42+
}, function ($item) {
43+
return $item;
44+
});
45+
46+
self::assertCount(3, $mapIterator);
47+
}
48+
2849
public function testConstructorException1(): void
2950
{
3051
$this->expectException('TheCodingMachine\TDBM\TDBMException');

0 commit comments

Comments
 (0)