Skip to content

Commit a2c8650

Browse files
[FrameworkBundle] Ensure container is reset between tests
1 parent e8dbdfc commit a2c8650

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Test/KernelTestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\ContainerInterface;
1616
use Symfony\Component\HttpKernel\KernelInterface;
17+
use Symfony\Contracts\Service\ResetInterface;
1718

1819
/**
1920
* KernelTestCase is the base class for tests needing a Kernel.
@@ -131,8 +132,13 @@ protected static function ensureKernelShutdown()
131132
{
132133
if (null !== static::$kernel) {
133134
static::$kernel->boot();
135+
$container = static::$kernel->getContainer();
134136
static::$kernel->shutdown();
135137
static::$booted = false;
138+
139+
if ($container instanceof ResetInterface) {
140+
$container->reset();
141+
}
136142
}
137143

138144
static::$container = null;

0 commit comments

Comments
 (0)