Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix KernelTestCase compatibility for PhpUnit 8 (bis)
- Loading branch information
1 parent
bb54e40
commit 1077df6
Showing
2 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Test; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the tearDown method | ||
|
||
if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { | ||
eval(' | ||
/** | ||
* @internal | ||
*/ | ||
trait KernelShutdownOnTearDownTrait | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
static::ensureKernelShutdown(); | ||
} | ||
} | ||
'); | ||
} else { | ||
/** | ||
* @internal | ||
*/ | ||
trait KernelShutdownOnTearDownTrait | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
protected function tearDown() | ||
{ | ||
static::ensureKernelShutdown(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters