Skip to content

Commit 353bc8a

Browse files
[HttpKernel] Reset services between requests performed by KernelBrowser
1 parent c3aaed5 commit 353bc8a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Client.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\HttpKernel\HttpKernelBrowser;
2020
use Symfony\Component\HttpKernel\KernelInterface;
2121
use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile;
22+
use Symfony\Contracts\Service\ResetInterface;
2223

2324
/**
2425
* Client simulates a browser and makes requests to a Kernel object.
@@ -116,7 +117,12 @@ protected function doRequest($request)
116117
// avoid shutting down the Kernel if no request has been performed yet
117118
// WebTestCase::createClient() boots the Kernel but do not handle a request
118119
if ($this->hasPerformedRequest && $this->reboot) {
120+
$container = $this->kernel->getContainer();
119121
$this->kernel->shutdown();
122+
123+
if ($container instanceof ResetInterface) {
124+
$container->reset();
125+
}
120126
} else {
121127
$this->hasPerformedRequest = true;
122128
}

Tests/KernelBrowserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testEnableRebootKernel()
5454
private function getKernelMock()
5555
{
5656
$mock = $this->getMockBuilder($this->getKernelClass())
57-
->setMethods(['shutdown', 'boot', 'handle'])
57+
->setMethods(['shutdown', 'boot', 'handle', 'getContainer'])
5858
->disableOriginalConstructor()
5959
->getMock();
6060

0 commit comments

Comments
 (0)