Skip to content

Commit c792f30

Browse files
authored
Fix the kernel shutdown with new versions of Symfony
1 parent 241bf0e commit c792f30

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/TestKernel.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ protected function configureRoutes($routes): void
183183

184184
public function shutdown(): void
185185
{
186+
if ($this->booted && $this->clearCache) {
187+
// KernelTestCase wants the services_resetter service to be instantiated as part of
188+
// its resetting in `ensureKernelShutdown`. However, if we clear the cache, the
189+
// compiled container will break when trying to load the file containing the compiled
190+
// code for that service as we would have deleted it already.
191+
// This runs before calling the parent method so that the container is still available.
192+
if ($this->container->has('services_resetter')) {
193+
$this->container->get('services_resetter')->reset();
194+
}
195+
}
196+
186197
parent::shutdown();
187198

188199
if (!$this->clearCache) {

0 commit comments

Comments
 (0)