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 18
18
use PHPUnit \Framework \Constraint \IsEqual ;
19
19
use PHPUnit \Framework \ExpectationFailedException ;
20
20
use PHPUnit \Framework \MockObject \Invocation as BaseInvocation ;
21
+ use PHPUnit \Util \Test ;
21
22
22
23
/**
23
24
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -105,6 +106,8 @@ private function doVerify(): bool
105
106
$ message .= "\nTo allow 0 or more parameters with any value, omit ->with() or use ->withAnyParameters() instead. " ;
106
107
}
107
108
109
+ $ this ->incrementAssertionCount ();
110
+
108
111
throw new ExpectationFailedException (
109
112
sprintf ($ message , $ this ->invocation ->toString ()),
110
113
);
@@ -117,6 +120,8 @@ private function doVerify(): bool
117
120
$ other = $ this ->invocation ->parameters ()[$ i ];
118
121
}
119
122
123
+ $ this ->incrementAssertionCount ();
124
+
120
125
$ parameter ->evaluate (
121
126
$ other ,
122
127
sprintf (
@@ -141,4 +146,9 @@ private function guardAgainstDuplicateEvaluationOfParameterConstraints(): bool
141
146
142
147
return (bool ) $ this ->parameterVerificationResult ;
143
148
}
149
+
150
+ private function incrementAssertionCount (): void
151
+ {
152
+ Test::currentTestCase ()->addToAssertionCount (1 );
153
+ }
144
154
}
Original file line number Diff line number Diff line change @@ -182,21 +182,6 @@ public function run(TestCase $test): void
182
182
183
183
ErrorHandler::instance ()->disable ();
184
184
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
-
200
185
if (!$ error &&
201
186
!$ incomplete &&
202
187
!$ skipped &&
Original file line number Diff line number Diff line change @@ -17,4 +17,4 @@ Runtime: %s
17
17
18
18
Time: %s, Memory: %s MB
19
19
20
- OK (2 tests, 2 assertions)
20
+ OK (2 tests, 4 assertions)
You can’t perform that action at this time.
0 commit comments