-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
type/bugSomething is brokenSomething is broken
Description
| Q | A |
|---|---|
| PHPUnit version | 8.2.3 |
| PHP version | 7.3.4 |
| Installation Method | Composer |
This assertion should not fail:
$this->assertCount(0, new \EmptyIterator());But it fails with an error:
1) Example::testEmptyIterator
BadMethodCallException: Accessing the key of an EmptyIterator
On the other hand this assertion works without a hitch:
$this->assertSame(0, iterator_count(new \EmptyIterator()));These seems to be the problematic lines:
phpunit/src/Framework/Constraint/Count.php
Lines 71 to 84 in 6efdf39
| $key = $iterator->key(); | |
| $count = \iterator_count($iterator); | |
| // Manually rewind $iterator to previous key, since iterator_count | |
| // moves pointer. | |
| if ($key !== null) { | |
| $iterator->rewind(); | |
| while ($iterator->valid() && $key !== $iterator->key()) { | |
| $iterator->next(); | |
| } | |
| } | |
| return $count; |
Metadata
Metadata
Assignees
Labels
type/bugSomething is brokenSomething is broken