Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The kernel reboot #130

Open
Legion112 opened this issue Apr 13, 2021 · 4 comments
Open

The kernel reboot #130

Legion112 opened this issue Apr 13, 2021 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@Legion112
Copy link

Legion112 commented Apr 13, 2021

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
@TavoNiievez
Copy link
Member

TavoNiievez commented Apr 13, 2021

@Legion112 could you please send a PR for this?

It would also help to have a test in our test project ( Codeception/symfony-module-tests ) with which we verify that your change solves the issue (and that it will not be damaged in future versions).

Please follow the contribution guide ( master/CONTRIBUTING.md ), and if all goes well I will gladly merge the changes.

@specdrum-agc
Copy link

Hello!

I also would like to notice that way this module is reboot Symfony Kernel differ from way doing that in Symfony KernelTestCase. Looks like this leads to services which implements Symfony\Contracts\Service\ResetInterface are not reset.

Look at symfony/symfony#40965 for example.

@TavoNiievez TavoNiievez added the help wanted Extra attention is needed label Oct 10, 2022
@namex42
Copy link

namex42 commented Mar 21, 2023

@Legion112 @TavoNiievez is there any progress on this issue? Thanks!

@Legion112
Copy link
Author

Sorry no longer work with codeception.

We used static variables for setting the state of stub classes.
This has one downside as it you need to reset the state between tests yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants