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
Disable persistentServices on Symfony Kernel reboot #3497
Comments
Because Doctrine2 module wraps a whole test in transaction and rolls back in All services were persisted between requests before rebootKernel was introduced. If you want more isolation, use a Db module of Codeception. |
Ok, tough on versions < 2.1.8 the persistentServices were not taken over to the next test file within the Symfony module, only between requests inside one test file. Besides that I found a solution to my problem by letting the REST module depend on PhpBrowser instead of Symfony. |
You have too many modules enabled - you should have only one of PhpBrowser and Symfony and one of Doctrine2 and Db. It is no longer allowed to have PhpBrowser and Symfony enabled in the same suite in Codeception 2.2 |
Yes I only had one of Symfony or PhpBrowser enabled as dependency via REST module. |
Was now able to test it. After removing the Doctrine2 module the tests also succeed when run together. So the following combination of enabled modules worked for me:
Tough because there where no conflicts with the combination of modules I thought they could be used together. I did use Doctrine2s grabFromRepository method (did now replace them by Symfony services) and Db modules cleanup/populate functioniality. Maybe there should be a notice on the docs if this is not recommend. So this was only a configuration issue and can be closed. |
What are you trying to achieve?
I have a simple REST api and trying to test default CRUD behaviour.
I am using Symfony 2.8 with the DoctrineExtensions::SoftDeleteable being enabled on the affected Entity. So when I am executing the request for DELETE on the Entity it gets soft deleted, on the next request I disable the doctrine filter for SoftDeleteable on the EntityManager, so I can retrieve the soft deleted entity again and delete it again (which results in a hard delete).
The next test file is doing the same on a different end point/entity.
What do you get instead?
The second test file fails because the doctrine service does not get recreated and therefore the filter on the EntityManager is still disabled.
This happens due to the doctrine and entity manager services are treat as persistent services inside the Codeception\Module\Symfony and Codeception\Lib\Connector\Symfony classes.
Removing the part where the stored persistentServices replace the ones from the rebooted container inside Codeception\Lib\Connector\Symfony::rebootKernel would solve the issue for me.
So why are there persistent services in the first place? Shouldn't the request being execute as isolated as possible? Could a new configuration option be implemented that we are able to disabled the usage of persistentServices?
Details
composer show
)global codeception.yml
api.suite.yml
The text was updated successfully, but these errors were encountered: