Skip to content

Commit de57965

Browse files
bug symfony#60693 [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass (cquintana92)
This PR was submitted for the 7.4 branch but it was squashed and merged into the 6.4 branch instead. Discussion ---------- [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | None | License | MIT Comes from symfony#60564 This PR performs the following change: In `KernelTestCase`, the kernel is shut down after every test, as per the `static::ensureKernelShutdown()` call in the `tearDown` function. However, if one was to perform any extra code in their `tearDownAfterClass` and call `getContainer`, it would boot up a new kernel, which would then be left dangling. The main issue with that is that when the next Test class is executed, there would already be a booted kernel, so it could happen that it was pointing to dangling resources. By adding this call to `static::ensureKernelShutdown` in the `tearDownAfterClass`, we can ensure that no dangling kernels are left even after the test class has finished. Commits ------- c193b98 [FrameworkBundle] ensureKernelShutdown in tearDownAfterClass
2 parents 0291ea1 + c193b98 commit de57965

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ protected function tearDown(): void
4545
static::$booted = false;
4646
}
4747

48+
public static function tearDownAfterClass(): void
49+
{
50+
static::ensureKernelShutdown();
51+
static::$class = null;
52+
static::$kernel = null;
53+
static::$booted = false;
54+
}
55+
4856
/**
4957
* @throws \RuntimeException
5058
* @throws \LogicException

0 commit comments

Comments
 (0)