module-symfony icon indicating copy to clipboard operation
module-symfony copied to clipboard

The kernel reboot

Open Legion112 opened this issue 3 years ago • 4 comments

I think the process of rebooting the kernel should be done right after the request has been finished. Here we have logic that will reboot the kernel only when a second request is made. https://github.com/Codeception/module-symfony/blob/master/src/Codeception/Lib/Connector/Symfony.php#L63 I think we should change it to:

    protected function doRequest($request): Response
    {
        $response = parent::doRequest($request);
        if ($this->rebootable) {
                $this->rebootKernel();
        }
        return $response;
    }

Why is it important? If the kernel is rebooted only when a second request happened - we cannot configure the "DI" container on the fly. Like setting Stubs classes. Something like this:

$I->sendGet('/some/path');
$stub = $I->grabServise(ExternalApiStub::clase);
$stub->setFakeResponse('This is a fake response from external API');
$I->sendGet('/some/path'); // here kernel rebootes and state of DI container is lost

Legion112 avatar Apr 13 '21 15:04 Legion112