Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new PHPUnit assertions for the WebTestCase #29990

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
Expand Up @@ -23,7 +23,7 @@
*/
abstract class KernelTestCase extends TestCase
{
use KernelShutdownOnTearDownTrait;
use TestCaseSetUpTearDownTrait;

protected static $class;

Expand All @@ -37,6 +37,11 @@ abstract class KernelTestCase extends TestCase
*/
protected static $container;

protected function doTearDown(): void
{
static::ensureKernelShutdown();
}

/**
* @return string The Kernel class name
*
Expand Down
Expand Up @@ -13,31 +13,60 @@

use PHPUnit\Framework\TestCase;

// Auto-adapt to PHPUnit 8 that added a `void` return-type to the tearDown method
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods

if ((new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) {
/**
* @internal
*/
trait KernelShutdownOnTearDownTrait
trait TestCaseSetUpTearDownTrait
{
private function doSetUp(): void
{
}

private function doTearDown(): void
{
}

protected function setUp(): void
{
$this->doSetUp();
}

protected function tearDown(): void
{
static::ensureKernelShutdown();
$this->doTearDown();
}
}
} else {
/**
* @internal
*/
trait KernelShutdownOnTearDownTrait
trait TestCaseSetUpTearDownTrait
{
private function doSetUp(): void
{
}

private function doTearDown(): void
{
}

/**
* @return void
*/
protected function setUp()
{
$this->doSetUp();
}

/**
* @return void
*/
protected function tearDown()
{
static::ensureKernelShutdown();
$this->doTearDown();
}
}
}