Skip to content

Commit 49dcba0

Browse files
Closes #6139
1 parent 7aed961 commit 49dcba0

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

src/Framework/MockObject/Runtime/Rule/Parameters.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\Constraint\IsEqual;
1919
use PHPUnit\Framework\ExpectationFailedException;
2020
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
21+
use PHPUnit\Util\Test;
2122

2223
/**
2324
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -105,6 +106,8 @@ private function doVerify(): bool
105106
$message .= "\nTo allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead.";
106107
}
107108

109+
$this->incrementAssertionCount();
110+
108111
throw new ExpectationFailedException(
109112
sprintf($message, $this->invocation->toString()),
110113
);
@@ -117,6 +120,8 @@ private function doVerify(): bool
117120
$other = $this->invocation->parameters()[$i];
118121
}
119122

123+
$this->incrementAssertionCount();
124+
120125
$parameter->evaluate(
121126
$other,
122127
sprintf(
@@ -141,4 +146,9 @@ private function guardAgainstDuplicateEvaluationOfParameterConstraints(): bool
141146

142147
return (bool) $this->parameterVerificationResult;
143148
}
149+
150+
private function incrementAssertionCount(): void
151+
{
152+
Test::currentTestCase()->addToAssertionCount(1);
153+
}
144154
}

src/Framework/TestRunner/TestRunner.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,6 @@ 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-
200185
if (!$error &&
201186
!$incomplete &&
202187
!$skipped &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Runtime: %s
1717

1818
Time: %s, Memory: %s MB
1919

20-
OK (2 tests, 2 assertions)
20+
OK (2 tests, 4 assertions)

0 commit comments

Comments
 (0)