diff --git a/src/Codeception/Lib/Connector/Symfony.php b/src/Codeception/Lib/Connector/Symfony.php index 44d7595a..0ea05923 100644 --- a/src/Codeception/Lib/Connector/Symfony.php +++ b/src/Codeception/Lib/Connector/Symfony.php @@ -37,19 +37,17 @@ public function __construct( /** @param Request $request */ protected function doRequest(object $request): Response { - if ($this->rebootable) { - if ($this->hasPerformedRequest) { - $this->rebootKernel(); - } else { - $this->hasPerformedRequest = true; - } + if ($this->hasPerformedRequest && $this->rebootable) { + $this->rebootKernel(); + } else { + $this->hasPerformedRequest = true; } return parent::doRequest($request); } /** - * Reboot kernel + * Reboots the kernel. * * Services from the list of persistent services * are updated from service container before kernel shutdown @@ -66,7 +64,8 @@ public function rebootKernel(): void } $this->persistDoctrineConnections(); - $this->kernel->reboot(null); + $this->ensureKernelShutdown(); + $this->kernel->boot(); $this->container = $this->getContainer(); foreach ($this->persistentServices as $serviceName => $service) { @@ -82,6 +81,12 @@ public function rebootKernel(): void } } + protected function ensureKernelShutdown(): void + { + $this->kernel->boot(); + $this->kernel->shutdown(); + } + private function getContainer(): ?ContainerInterface { /** @var ContainerInterface $container */ @@ -120,7 +125,9 @@ private function persistDoctrineConnections(): void } $reflectedContainer = new ReflectionClass($publicContainer); - $reflectionTarget = $reflectedContainer->hasProperty('parameters') ? $publicContainer : $publicContainer->getParameterBag(); + $reflectionTarget = $reflectedContainer->hasProperty('parameters') + ? $publicContainer + : $publicContainer->getParameterBag(); $reflectedParameters = new ReflectionProperty($reflectionTarget, 'parameters'); $reflectedParameters->setAccessible(true);