Skip to content

Commit 70e07ce

Browse files
committed
[FrameworkBundle] Fix getting the container from a non-booted kernel in KernelBrowser
1 parent f432349 commit 70e07ce

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Client.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ protected function doRequest($request)
117117
// avoid shutting down the Kernel if no request has been performed yet
118118
// WebTestCase::createClient() boots the Kernel but do not handle a request
119119
if ($this->hasPerformedRequest && $this->reboot) {
120-
$container = $this->kernel->getContainer();
120+
try {
121+
$container = $this->kernel->getContainer();
122+
} catch (\LogicException $e) {
123+
$container = null;
124+
}
125+
121126
$this->kernel->shutdown();
122127

123128
if ($container instanceof ResetInterface) {

src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ public function testEnableRebootKernel()
5151
$client->request('GET', '/');
5252
}
5353

54+
public function testRequestAfterKernelShutdownAndPerformedRequest()
55+
{
56+
$this->expectNotToPerformAssertions();
57+
58+
$client = static::createClient(['test_case' => 'TestServiceContainer']);
59+
$client->request('GET', '/');
60+
static::ensureKernelShutdown();
61+
$client->request('GET', '/');
62+
}
63+
5464
private function getKernelMock()
5565
{
5666
$mock = $this->getMockBuilder($this->getKernelClass())

0 commit comments

Comments
 (0)