Skip to content

Commit ffd57af

Browse files
Closes #6138
1 parent e8d395a commit ffd57af

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

ChangeLog-11.5.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
## [11.5.10] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6138](https://github.com/sebastianbergmann/phpunit/issues/6138): Test with failed expectation on value passed to mocked method is incorrectly considered risky
10+
511
## [11.5.9] - 2025-02-21
612

713
### Fixed
@@ -111,6 +117,7 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi
111117
* [#6055](https://github.com/sebastianbergmann/phpunit/issues/6055): `assertNotContainsOnly()` (use `assertContainsNotOnlyArray()`, `assertContainsNotOnlyBool()`, `assertContainsNotOnlyCallable()`, `assertContainsNotOnlyFloat()`, `assertContainsNotOnlyInt()`, `assertContainsNotOnlyIterable()`, `assertContainsNotOnlyNumeric()`, `assertContainsNotOnlyObject()`, `assertContainsNotOnlyResource()`, `assertContainsNotOnlyClosedResource()`, `assertContainsNotOnlyScalar()`, or `assertContainsNotOnlyString()` instead)
112118
* [#6059](https://github.com/sebastianbergmann/phpunit/issues/6059): `containsOnly()` (use `containsOnlyArray()`, `containsOnlyBool()`, `containsOnlyCallable()`, `containsOnlyFloat()`, `containsOnlyInt()`, `containsOnlyIterable()`, `containsOnlyNumeric()`, `containsOnlyObject()`, `containsOnlyResource()`, `containsOnlyClosedResource()`, `containsOnlyScalar()`, or `containsOnlyString()` instead)
113119

120+
[11.5.10]: https://github.com/sebastianbergmann/phpunit/compare/11.5.9...11.5
114121
[11.5.9]: https://github.com/sebastianbergmann/phpunit/compare/11.5.8...11.5.9
115122
[11.5.8]: https://github.com/sebastianbergmann/phpunit/compare/11.5.7...11.5.8
116123
[11.5.7]: https://github.com/sebastianbergmann/phpunit/compare/11.5.6...11.5.7

src/Framework/TestRunner/TestRunner.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ public function run(TestCase $test): void
182182

183183
ErrorHandler::instance()->disable();
184184

185+
/**
186+
* Workaround for tests that fail due to mock object expectations
187+
* that are verified while the test is running and not after the
188+
* test has finished running
189+
*
190+
* @see https://github.com/sebastianbergmann/phpunit/issues/6138
191+
*/
192+
if ($failure &&
193+
!$error &&
194+
!$incomplete &&
195+
!$skipped &&
196+
$test->numberOfAssertionsPerformed() === 0) {
197+
$test->addToAssertionCount(1);
198+
}
199+
185200
if (!$error &&
186201
!$incomplete &&
187202
!$skipped &&

tests/end-to-end/regression/6138.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
https://github.com/sebastianbergmann/phpunit/issues/6138
3-
--XFAIL--
4-
https://github.com/sebastianbergmann/phpunit/issues/6138
53
--FILE--
64
<?php declare(strict_types=1);
75
$_SERVER['argv'][] = '--do-not-cache-result';

0 commit comments

Comments
 (0)