From 592a00a3dc13cda0635854d804666fc69d59a20b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 19 Feb 2022 00:07:57 +0100 Subject: [PATCH] [HttpKernel] Reset services between requests performed by KernelBrowser --- src/Symfony/Bundle/FrameworkBundle/Client.php | 6 ++++++ .../Bundle/FrameworkBundle/Tests/KernelBrowserTest.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 174b024e21c79..a27a7141dfba2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -19,6 +19,7 @@ use Symfony\Component\HttpKernel\HttpKernelBrowser; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile; +use Symfony\Contracts\Service\ResetInterface; /** * Client simulates a browser and makes requests to a Kernel object. @@ -116,7 +117,12 @@ protected function doRequest($request) // avoid shutting down the Kernel if no request has been performed yet // WebTestCase::createClient() boots the Kernel but do not handle a request if ($this->hasPerformedRequest && $this->reboot) { + $container = $this->kernel->getContainer(); $this->kernel->shutdown(); + + if ($container instanceof ResetInterface) { + $container->reset(); + } } else { $this->hasPerformedRequest = true; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php index 2770813d8a696..96eaaea7612af 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php @@ -54,7 +54,7 @@ public function testEnableRebootKernel() private function getKernelMock() { $mock = $this->getMockBuilder($this->getKernelClass()) - ->setMethods(['shutdown', 'boot', 'handle']) + ->setMethods(['shutdown', 'boot', 'handle', 'getContainer']) ->disableOriginalConstructor() ->getMock();