From 4525540c222114e2aa697c78bafb79aef18c5323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 30 Sep 2019 18:52:44 +0200 Subject: [PATCH] Improving code coverage --- tests/EmptyInnerResultIteratorTest.php | 5 ++++- tests/MapIteratorTest.php | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/EmptyInnerResultIteratorTest.php b/tests/EmptyInnerResultIteratorTest.php index 8c53a4e2..0c079576 100644 --- a/tests/EmptyInnerResultIteratorTest.php +++ b/tests/EmptyInnerResultIteratorTest.php @@ -38,7 +38,10 @@ public function testIterate() foreach ($iterator as $elem) { $this->fail('Iterator should be empty'); } - $this->assertTrue(true); + + $iterator->next(); + $this->assertNull($iterator->current()); + $this->assertNull($iterator->key()); } public function testOffsetGet() diff --git a/tests/MapIteratorTest.php b/tests/MapIteratorTest.php index 9a16ddd6..20fda9bc 100644 --- a/tests/MapIteratorTest.php +++ b/tests/MapIteratorTest.php @@ -21,10 +21,31 @@ namespace TheCodingMachine\TDBM; +use ArrayIterator; +use IteratorAggregate; use PHPUnit\Framework\TestCase; class MapIteratorTest extends TestCase { + public function testIteratorAggregate(): void + { + $mapIterator = new MapIterator(new class implements IteratorAggregate + { + public $property1 = "Public property one"; + public $property2 = "Public property two"; + public $property3 = "Public property three"; + + public function getIterator() + { + return new ArrayIterator($this); + } + }, function ($item) { + return $item; + }); + + self::assertCount(3, $mapIterator); + } + public function testConstructorException1(): void { $this->expectException('TheCodingMachine\TDBM\TDBMException');