File tree Expand file tree Collapse file tree 4 files changed +434
-7
lines changed
Expand file tree Collapse file tree 4 files changed +434
-7
lines changed Original file line number Diff line number Diff line change 2323 */
2424abstract 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 *
Original file line number Diff line number Diff line change 1313
1414use 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
1818if ((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}
You can’t perform that action at this time.
0 commit comments