File tree Expand file tree Collapse file tree 3 files changed +11
-16
lines changed
tests/end-to-end/regression Expand file tree Collapse file tree 3 files changed +11
-16
lines changed Original file line number Diff line number Diff line change 1818use PHPUnit \Framework \Constraint \IsEqual ;
1919use PHPUnit \Framework \ExpectationFailedException ;
2020use 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}
Original file line number Diff line number Diff 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 &&
Original file line number Diff line number Diff line change @@ -17,4 +17,4 @@ Runtime: %s
1717
1818Time: %s, Memory: %s MB
1919
20- OK (2 tests, 2 assertions)
20+ OK (2 tests, 4 assertions)
You can’t perform that action at this time.
0 commit comments