diff --git a/src/Codeception/Lib/Connector/Symfony.php b/src/Codeception/Lib/Connector/Symfony.php index 656583eb..0d290ba9 100644 --- a/src/Codeception/Lib/Connector/Symfony.php +++ b/src/Codeception/Lib/Connector/Symfony.php @@ -55,8 +55,6 @@ public function rebootKernel(): void { $this->updatePersistentServices(); - $this->persistDoctrineConnections(); - if ($this->kernel instanceof Kernel) { $this->ensureKernelShutdown(); $this->kernel->boot(); @@ -72,7 +70,20 @@ public function rebootKernel(): void protected function ensureKernelShutdown(): void { $this->kernel->boot(); - $this->kernel->shutdown(); + + $kernel = $this->kernel; + (function () use ($kernel): void { + if (!property_exists($this, 'parameters') || !is_array($this->parameters)) { + $kernel->shutdown(); + return; + } + $connections = $this->parameters['doctrine.connections'] ?? null; + unset($this->parameters['doctrine.connections']); + $kernel->shutdown(); + if ($connections !== null) { + $this->parameters['doctrine.connections'] = $connections; + } + })->call($kernel->getContainer()); } private function resolveContainer(): ContainerInterface @@ -98,15 +109,6 @@ private function getProfiler(): ?Profiler return null; } - private function persistDoctrineConnections(): void - { - (function (): void { - if (property_exists($this, 'parameters') && is_array($this->parameters)) { - unset($this->parameters['doctrine.connections']); - } - })->call($this->kernel->getContainer()); - } - private function updatePersistentServices(): void { foreach ($this->persistentServices as $name => $_) {