Skip to content

Commit c55322b

Browse files
committed
Ensure congruence with the flow in the Symfony KernelTestCase
1 parent 4ee70f9 commit c55322b

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/Codeception/Lib/Connector/Symfony.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ public function __construct(
3131
parent::__construct($kernel);
3232
$this->followRedirects();
3333
$this->container = $this->getContainer();
34-
$this->rebootKernel(); // Ensure the profiler exists
34+
$this->rebootKernel();
3535
}
3636

3737
/** @param Request $request */
3838
protected function doRequest(object $request): Response
3939
{
40-
if ($this->hasPerformedRequest && $this->rebootable) {
41-
$this->rebootKernel();
42-
} else {
43-
$this->hasPerformedRequest = true;
40+
if ($this->rebootable) {
41+
if ($this->hasPerformedRequest) {
42+
$this->rebootKernel();
43+
} else {
44+
$this->hasPerformedRequest = true;
45+
}
4446
}
4547

4648
return parent::doRequest($request);
4749
}
4850

4951
/**
50-
* Reboot kernel
52+
* Reboots the kernel.
5153
*
5254
* Services from the list of persistent services
5355
* are updated from service container before kernel shutdown
@@ -64,8 +66,7 @@ public function rebootKernel(): void
6466
}
6567

6668
$this->persistDoctrineConnections();
67-
$this->kernel->boot();
68-
$this->kernel->shutdown();
69+
$this->ensureKernelShutdown();
6970
$this->kernel->boot();
7071
$this->container = $this->getContainer();
7172

@@ -82,6 +83,12 @@ public function rebootKernel(): void
8283
}
8384
}
8485

86+
protected function ensureKernelShutdown(): void
87+
{
88+
$this->kernel->boot();
89+
$this->kernel->shutdown();
90+
}
91+
8592
private function getContainer(): ?ContainerInterface
8693
{
8794
/** @var ContainerInterface $container */

0 commit comments

Comments
 (0)