Skip to content

Commit 6093ee5

Browse files
Merge branch '10.5' into 11.5
2 parents 9acd977 + de0c82c commit 6093ee5

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
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.3] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6095](https://github.com/sebastianbergmann/phpunit/issues/6095): Expectation is not counted correctly when a doubled method is called more often than is expected
10+
511
## [11.5.2] - 2024-12-21
612

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

53+
[11.5.3]: https://github.com/sebastianbergmann/phpunit/compare/11.5.2...11.5
4754
[11.5.2]: https://github.com/sebastianbergmann/phpunit/compare/11.5.1...11.5.2
4855
[11.5.1]: https://github.com/sebastianbergmann/phpunit/compare/11.5.0...11.5.1
4956
[11.5.0]: https://github.com/sebastianbergmann/phpunit/compare/11.4.4...11.5.0

src/Framework/TestCase.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
use PHPUnit\Framework\MockObject\Rule\InvokedAtLeastCount as InvokedAtLeastCountMatcher;
7777
use PHPUnit\Framework\MockObject\Rule\InvokedAtLeastOnce as InvokedAtLeastOnceMatcher;
7878
use PHPUnit\Framework\MockObject\Rule\InvokedAtMostCount as InvokedAtMostCountMatcher;
79+
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
7980
use PHPUnit\Framework\MockObject\Rule\InvokedCount as InvokedCountMatcher;
8081
use PHPUnit\Framework\MockObject\Stub;
8182
use PHPUnit\Framework\MockObject\Stub\ConsecutiveCalls as ConsecutiveCallsStub;
@@ -532,6 +533,8 @@ final public function runBare(): void
532533
$e->getMessage(),
533534
);
534535
} catch (AssertionError|AssertionFailedError $e) {
536+
$this->handleExceptionFromInvokedCountMockObjectRule($e);
537+
535538
if (!$this->wasPrepared) {
536539
$this->wasPrepared = true;
537540

@@ -2574,6 +2577,22 @@ private function requirementsNotSatisfied(): bool
25742577
return (new Requirements)->requirementsNotSatisfiedFor(static::class, $this->methodName) !== [];
25752578
}
25762579

2580+
/**
2581+
* @see https://github.com/sebastianbergmann/phpunit/issues/6095
2582+
*/
2583+
private function handleExceptionFromInvokedCountMockObjectRule(Throwable $t): void
2584+
{
2585+
if (!$t instanceof ExpectationFailedException) {
2586+
return;
2587+
}
2588+
2589+
$trace = $t->getTrace();
2590+
2591+
if (isset($trace[0]['class']) && $trace[0]['class'] === InvokedCount::class) {
2592+
$this->numberOfAssertionsPerformed++;
2593+
}
2594+
}
2595+
25772596
/**
25782597
* Creates a test stub for the specified interface or class.
25792598
*

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
https://github.com/sebastianbergmann/phpunit/issues/6095
3-
--XFAIL--
4-
https://github.com/sebastianbergmann/phpunit/issues/6095
53
--FILE--
64
<?php declare(strict_types=1);
75
$_SERVER['argv'][] = '--do-not-cache-result';
@@ -23,7 +21,7 @@ Time: %s, Memory: %s
2321
There was 1 failure:
2422

2523
1) PHPUnit\TestFixture\Issue6095\Issue6095Test::testOne
26-
PHPUnit\TestFixture\MockObject\AnInterface::doSomething() was not expected to be called more than once.
24+
PHPUnit\TestFixture\MockObject\AnInterface::doSomething(): bool was not expected to be called more than once.
2725

2826
%sIssue6095Test.php:26
2927

0 commit comments

Comments
 (0)