Skip to content

Commit ed77a62

Browse files
committed
Merge branch '6.4' into 7.3
* 6.4: do not try to modify the result of a PhptTestCase
2 parents 43f3fcc + 406aa80 commit ed77a62

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Legacy/SymfonyTestsListenerTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ public function endTest($test, $time): void
280280

281281
if ($this->checkNumAssertions) {
282282
$assertions = \count(self::$expectedDeprecations) + $test->getNumAssertions();
283-
if ($test->doesNotPerformAssertions() && $assertions > 0) {
283+
if ($test instanceof TestCase && $test->doesNotPerformAssertions() && $assertions > 0) {
284284
$test->getTestResultObject()->addFailure($test, new RiskyTestError(sprintf('This test is annotated with "@doesNotPerformAssertions", but performed %s assertions', $assertions)), $time);
285-
} elseif ($assertions === 0 && !$test->doesNotPerformAssertions() && $test->getTestResultObject()->noneSkipped()) {
285+
} elseif ($test instanceof TestCase && $assertions === 0 && !$test->doesNotPerformAssertions() && $test->getTestResultObject()->noneSkipped()) {
286286
$test->getTestResultObject()->addFailure($test, new RiskyTestError('This test did not perform any assertions'), $time);
287287
}
288288

@@ -312,9 +312,9 @@ public function endTest($test, $time): void
312312

313313
restore_error_handler();
314314

315-
if (!\in_array('legacy', $groups, true)) {
315+
if ($test instanceof TestCase && !\in_array('legacy', $groups, true)) {
316316
$test->getTestResultObject()->addError($test, new AssertionFailedError('Only tests with the "@group legacy" annotation can expect a deprecation.'), 0);
317-
} elseif (!\in_array($test->getStatus(), [BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR], true)) {
317+
} elseif ($test instanceof TestCase && !\in_array($test->getStatus(), [BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR], true)) {
318318
try {
319319
$prefix = "@expectedDeprecation:\n";
320320
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", self::$expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", self::$gatheredDeprecations)."\n");

0 commit comments

Comments
 (0)