Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6d881f7

Browse filesBrowse files
committed
bug #30124 Fix KernelTestCase compatibility for PhpUnit 8 (bis) (nicolas-grekas)
This PR was squashed before being merged into the 3.4 branch (closes #30124). Discussion ---------- Fix KernelTestCase compatibility for PhpUnit 8 (bis) | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Follow up of #30084 and @Tobion's comment there. Fabbot failure is a false-positive. Commits ------- 1077df6 Fix KernelTestCase compatibility for PhpUnit 8 (bis)
2 parents e3ceb1f + 1077df6 commit 6d881f7
Copy full SHA for 6d881f7

File tree

Expand file treeCollapse file tree

2 files changed

+48
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+48
-3
lines changed
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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\Bundle\FrameworkBundle\Test;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the tearDown method
17+
18+
if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) {
19+
eval('
20+
/**
21+
* @internal
22+
*/
23+
trait KernelShutdownOnTearDownTrait
24+
{
25+
protected function tearDown(): void
26+
{
27+
static::ensureKernelShutdown();
28+
}
29+
}
30+
');
31+
} else {
32+
/**
33+
* @internal
34+
*/
35+
trait KernelShutdownOnTearDownTrait
36+
{
37+
/**
38+
* @return void
39+
*/
40+
protected function tearDown()
41+
{
42+
static::ensureKernelShutdown();
43+
}
44+
}
45+
}

‎src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
abstract class KernelTestCase extends TestCase
2525
{
26+
use KernelShutdownOnTearDownTrait;
27+
2628
protected static $class;
2729

2830
/**
@@ -208,9 +210,7 @@ protected static function createKernel(array $options = [])
208210
}
209211

210212
/**
211-
* @after
212-
*
213-
* Shuts the kernel down if it was used in the test.
213+
* Shuts the kernel down if it was used in the test - called by the tearDown method by default.
214214
*/
215215
protected static function ensureKernelShutdown()
216216
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.