Skip to content

Commit 6d6baff

Browse files
bug #35489 [PhpUnitBridge] Fix running skipped tests expecting only deprecations (chalasr)
This PR was merged into the 3.4 branch. Discussion ---------- [PhpUnitBridge] Fix running skipped tests expecting only deprecations | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - If a test class has unsatisfied `@requires` and contains test methods expecting deprecation only, you get: > Fatal error: Uncaught Error: Call to a member function beStrictAboutTestsThatDoNotTestAnything() on null in ./symfony/symfony-dev/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListenerTrait.php:229 Spotted in #34925's build. Commits ------- 6b02362c5b [Phpunit] Fix running skipped tests expecting only deprecations
2 parents 313ee84 + e1398f0 commit 6d6baff

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Legacy/SymfonyTestsListenerTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ public function startTest($test)
222222
}
223223
}
224224

225+
if (!$test->getTestResultObject()) {
226+
return;
227+
}
228+
225229
$annotations = $Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
226230

227231
if (isset($annotations['class']['expectedDeprecation'])) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* This test is meant to be skipped.
18+
*
19+
* @requires extension ext-dummy
20+
*/
21+
final class OnlyExpectingDeprecationSkippedTest extends TestCase
22+
{
23+
/**
24+
* Do not remove this test in the next major versions.
25+
*
26+
* @group legacy
27+
*
28+
* @expectedDeprecation unreachable
29+
*/
30+
public function testExpectingOnlyDeprecations()
31+
{
32+
$this->fail('should never be ran.');
33+
}
34+
}

0 commit comments

Comments
 (0)