-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Stuck between DAMA and FOUNDRY/RESTDATABASE #251
Comments
Hey @DigitalTimK, I believe I understand the problem but I don't know there is a great solution. The logic to "change how reset database" resets the database when Dama is enabled assumes you are running it for your entire suite. To clarify, does your test suite run successfully if Dama is disabled? For you app, what about grouping the panther tests together and running them as a separate run with Dama disabled? It would require a second phpunit.xml which is unfortunate. For a proper solution, I think we may have to wait until PHPUnit 10's event system as suggested here, and for DAMA to utilize these events. |
Hello @kbond, thanks for your response. I am not the best friend of the second phpunit.xml workaround. But as it isn't that urgent currently I will hope and wait for PHPUnit 10 ;-) But what makes me really wonder is that I am the first coming up with the issue. Nobody doing functional testing? |
To clarify, this is a problem if using Foundry, DAMA, and Panther together. I suspect it must be rare to use all three in the same suite? My functional tests use Foundry, DAMA and the standard kernel browser (no panther). |
Hello @kbond , I'm having this problem too, I need Panther to test an app that uses Symfony UX, so lots of javascript. Is there an approach you recommend to take advantage of fixtures with Panther? |
Hi @Cafeine42, at this point, you'll need to create a second panther-specific phpunit.xml that doesn't have DAMA enabled.
You'll have to run two test suites: phpunit -c phpunit.xml # unit/integration tests
phpunit -c phpunit-panther.xml #e2e/panther tests |
I think there is no other solution than using two configuration files 🤷 |
Good Morning!
Epilogue
To be honest, maybe I am doing something totally wrong, since my issue is a common use-case, but it seems that I am the only one having this issue.
Environment
5.4
DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension
-extensionZenstruck\Foundry\Test\ResetDatabase
Use Case
PantherTestCase
) of a simple contact form (name, email-address, message) on a website$person = PersonFactory::createOne(['email' => '[email protected]']);
) before the form is filled and submitted.Problem 1
Once the form is submitted by the test it gets treated by the controller, but the Person-object is not existing anymore (the entire database is empty). The database seems be rolled back by DAMA.
Solution 1
According to the proposal here, I added this to the above mentioned function test-class.
Problem 2
Solution 1 is working perfectly. But only if that test is executed in isolation. Once the full test-set is launched it explodes for subsequent tests with:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'something' for key 'PRIMARY'
So it seems that RESTDATABASE is not executed anymore from that test-class and on ...
Solution 2
--> I have no idea how to solve this. Any idea?
Or is this a bug?
Many thanks for sharing your thoughts!
Cheers
Tim!
The text was updated successfully, but these errors were encountered: