Skip to content

Commit 2f8040e

Browse files
Pierstovalfabpot
authored andcommitted
Create new PHPUnit assertions for the WebTestCase
1 parent b921076 commit 2f8040e

File tree

6 files changed

+438
-23
lines changed

6 files changed

+438
-23
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
abstract class KernelTestCase extends TestCase
2525
{
26-
use KernelShutdownOnTearDownTrait;
26+
use TestCaseSetUpTearDownTrait;
2727

2828
protected static $class;
2929

@@ -37,6 +37,11 @@ abstract class KernelTestCase extends TestCase
3737
*/
3838
protected static $container;
3939

40+
protected function doTearDown(): void
41+
{
42+
static::ensureKernelShutdown();
43+
}
44+
4045
/**
4146
* @return string The Kernel class name
4247
*

src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php renamed to src/Symfony/Bundle/FrameworkBundle/Test/TestCaseSetUpTearDownTrait.php

+34-5
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,60 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515

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

1818
if ((new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) {
1919
/**
2020
* @internal
2121
*/
22-
trait KernelShutdownOnTearDownTrait
22+
trait TestCaseSetUpTearDownTrait
2323
{
24+
private function doSetUp(): void
25+
{
26+
}
27+
28+
private function doTearDown(): void
29+
{
30+
}
31+
32+
protected function setUp(): void
33+
{
34+
$this->doSetUp();
35+
}
36+
2437
protected function tearDown(): void
2538
{
26-
static::ensureKernelShutdown();
39+
$this->doTearDown();
2740
}
2841
}
2942
} else {
3043
/**
3144
* @internal
3245
*/
33-
trait KernelShutdownOnTearDownTrait
46+
trait TestCaseSetUpTearDownTrait
3447
{
48+
private function doSetUp(): void
49+
{
50+
}
51+
52+
private function doTearDown(): void
53+
{
54+
}
55+
56+
/**
57+
* @return void
58+
*/
59+
protected function setUp()
60+
{
61+
$this->doSetUp();
62+
}
63+
3564
/**
3665
* @return void
3766
*/
3867
protected function tearDown()
3968
{
40-
static::ensureKernelShutdown();
69+
$this->doTearDown();
4170
}
4271
}
4372
}

0 commit comments

Comments
 (0)