diff --git a/.travis.yml b/.travis.yml index cbe9517..de526eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -dist: trusty language: php php: @@ -6,7 +5,7 @@ php: - 7.2 install: - - composer install --prefer-dist + - composer install script: - vendor/bin/phpunit diff --git a/composer.json b/composer.json index 288922e..892d93e 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,16 @@ "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~7.0" + "phpunit/phpunit": "^7.0" }, "autoload": { "files": ["src/bootstrap.php"] }, + "autoload-dev": { + "psr-4": { + "iter\\": "test" + } + }, "extra": { "branch-alias": { "dev-master": "2.0-dev" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0e317e9..cc14a19 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="./src/bootstrap.php"> + bootstrap="./vendor/autoload.php"> ./test/ @@ -18,7 +18,10 @@ - ./lib/ + src + + src/bootstrap.php + - \ No newline at end of file + diff --git a/src/bootstrap.php b/src/bootstrap.php index 2bdb16f..61b3f2a 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -2,4 +2,4 @@ require __DIR__ . '/iter.fn.php'; require __DIR__ . '/iter.php'; -require __DIR__ . '/iter.rewindable.php'; \ No newline at end of file +require __DIR__ . '/iter.rewindable.php'; diff --git a/test/MyIterator.php b/test/MyIterator.php new file mode 100644 index 0000000..a2ca360 --- /dev/null +++ b/test/MyIterator.php @@ -0,0 +1,36 @@ +position = 0; + } + + public function rewind() { + $this->position = 0; + } + + public function current() { + return $this->array[$this->position]; + } + + public function key() { + return $this->position; + } + + public function next() { + ++$this->position; + } + + public function valid() { + return isset($this->array[$this->position]); + } +} diff --git a/test/MyIteratorAgg.php b/test/MyIteratorAgg.php new file mode 100644 index 0000000..5bee9e8 --- /dev/null +++ b/test/MyIteratorAgg.php @@ -0,0 +1,17 @@ +property4 = "last property"; + } + + public function getIterator() { + return new \ArrayIterator($this); + } +} diff --git a/test/iterTest.php b/test/iterTest.php index e8311dc..dd0ec48 100644 --- a/test/iterTest.php +++ b/test/iterTest.php @@ -366,6 +366,11 @@ public function testIsEmpty() { $this->assertFalse(isEmpty(toArray([null]))); $this->assertTrue(isEmpty(repeat(42, 0))); $this->assertFalse(isEmpty(repeat(42))); + $this->assertFalse(isEmpty(new MyIteratorAgg())); + } + + public function testCountWithValidIteratorAgg() { + $this->assertSame(4, count(new MyIteratorAgg())); } public function testToArray() {