44
55namespace Codeception \Lib \Connector ;
66
7+ use Doctrine \ORM \EntityManagerInterface ;
8+ use Doctrine \Persistence \ManagerRegistry ;
79use InvalidArgumentException ;
810use Symfony \Component \DependencyInjection \ContainerInterface ;
911use Symfony \Component \HttpFoundation \Response ;
@@ -55,7 +57,7 @@ public function rebootKernel(): void
5557 {
5658 $ this ->updatePersistentServices ();
5759
58- $ this ->persistDoctrineConnections ();
60+ $ this ->keepDoctrineConnectionsOpen ();
5961
6062 if ($ this ->kernel instanceof Kernel) {
6163 $ this ->ensureKernelShutdown ();
@@ -96,7 +98,7 @@ private function getProfiler(): ?Profiler
9698 return $ profiler instanceof Profiler ? $ profiler : null ;
9799 }
98100
99- private function persistDoctrineConnections (): void
101+ private function keepDoctrineConnectionsOpen (): void
100102 {
101103 (function (): void {
102104 if (property_exists ($ this , 'parameters ' ) && is_array ($ this ->parameters )) {
@@ -117,6 +119,9 @@ private function updatePersistentServices(): void
117119 private function injectPersistentServices (): void
118120 {
119121 foreach ($ this ->persistentServices as $ name => $ service ) {
122+ if ($ service instanceof EntityManagerInterface || $ service instanceof ManagerRegistry) {
123+ continue ;
124+ }
120125 try {
121126 $ this ->container ->set ($ name , $ service );
122127 } catch (InvalidArgumentException $ e ) {
0 commit comments