8000 [Bridge] Corrects bug in test listener trait · symfony/symfony@ebf388a · GitHub
[go: up one dir, main page]

Skip to content

Commit ebf388a

Browse files
committed
[Bridge] Corrects bug in test listener trait
If you enable the `SymfonyTestsListenerTrait`, use the `ExpectDeprecationTrait`, and call `$this->expectNotToPerformAssertions()`, an error was returned in your test saying it was risky as it did not perform any assertions even though it was expected not to. This bug turned out to be caused by not checking if the `doesNotPerformAssertions` flag had been set. Issue: #41444
1 parent b893a71 commit ebf388a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function endTest($test, $time)
271271
$assertions = \count(self::$expectedDeprecations) + $test->getNumAssertions();
272272
if ($test->doesNotPerformAssertions() && $assertions > 0) {
273273
$test->getTestResultObject()->addFailure($test, new RiskyTestError(sprintf('This test is annotated with "@doesNotPerformAssertions", but performed %s assertions', $assertions)), $time);
274-
} elseif ($assertions === 0 && $test->getTestResultObject()->noneSkipped()) {
274+
} elseif ($assertions === 0 && !$test->doesNotPerformAssertions() && $test->getTestResultObject()->noneSkipped()) {
275275
$test->getTestResultObject()->addFailure($test, new RiskyTestError('This test did not perform any assertions'), $time);
276276
}
277277

0 commit comments

Comments
 (0)
0