Skip to content

Commit

Permalink
Merge branch '8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 2, 2019
2 parents 29f3849 + ee343b9 commit 23544ff
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-7.5.md
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 7.5 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [7.5.14] - 2019-MM-DD

### Fixed

* Fixed [#3743](https://github.com/sebastianbergmann/phpunit/issues/3743): `EmptyIterator` instances are not handled correctly by `Count` and `IsEmpty` constraints

## [7.5.13] - 2019-06-19

### Fixed
Expand Down Expand Up @@ -126,6 +132,7 @@ All notable changes of the PHPUnit 7.5 release series are documented in this fil
* Fixed [#3429](https://github.com/sebastianbergmann/phpunit/pull/3429): Inefficient loop in `getHookMethods()`
* Fixed [#3437](https://github.com/sebastianbergmann/phpunit/pull/3437): JUnit logger skips PHPT tests

[7.5.14]: https://github.com/sebastianbergmann/phpunit/compare/7.5.13...7.5.14
[7.5.13]: https://github.com/sebastianbergmann/phpunit/compare/7.5.12...7.5.13
[7.5.12]: https://github.com/sebastianbergmann/phpunit/compare/7.5.11...7.5.12
[7.5.11]: https://github.com/sebastianbergmann/phpunit/compare/7.5.10...7.5.11
Expand Down
4 changes: 4 additions & 0 deletions src/Framework/Constraint/Count.php
Expand Up @@ -49,6 +49,10 @@ protected function matches($other): bool
*/
protected function getCountOf($other): ?int
{
if ($other instanceof \EmptyIterator) {
return 0;
}

if ($other instanceof Countable || \is_array($other)) {
return \count($other);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Framework/Constraint/IsEmpty.php
Expand Up @@ -32,6 +32,10 @@ public function toString(): string
*/
protected function matches($other): bool
{
if ($other instanceof \EmptyIterator) {
return true;
}

if ($other instanceof Countable) {
return \count($other) === 0;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/Framework/Constraint/CountTest.php
Expand Up @@ -173,4 +173,14 @@ public function testCountEvaluateReturnsNullWithNonCountableAndNonTraversableOth
);
}
}

/**
* @ticket https://github.com/sebastianbergmann/phpunit/issues/3743
*/
public function test_EmptyIterator_is_handled_correctly(): void
{
$constraint = new Count(0);

$this->assertTrue($constraint->evaluate(new \EmptyIterator, '', true));
}
}
10 changes: 10 additions & 0 deletions tests/unit/Framework/Constraint/IsEmptyTest.php
Expand Up @@ -67,4 +67,14 @@ public function testConstraintIsEmpty2(): void

$this->fail();
}

/**
* @ticket https://github.com/sebastianbergmann/phpunit/issues/3743
*/
public function test_EmptyIterator_is_handled_correctly(): void
{
$constraint = new IsEmpty;

$this->assertTrue($constraint->evaluate(new \EmptyIterator, '', true));
}
}

0 comments on commit 23544ff

Please sign in to comment.