Database Cleanup in Symfony2 Tests

Is there a standard way to clear your database before (or after) each test when testing with Symfony2 / PHPUnit? There seems to be a standard, obvious way to do this in Rails, but I have not found an analogue in the Symfony community.

+4
source share
2 answers

You can clear the tables with Doctrine data purger or rebuild the schema before each test.

Purger is included in the data package: https://github.com/doctrine/data-fixtures

I once wrote KernelAwareTest, which rebuilds the circuit before each test: https://gist.github.com/1319290

+1
source

If you use the LiipFunctionalTestBundle , the database is cleared every time the fixtures are loaded. If you do not need any loadable appliances, you can still call $this->loadFixtures(array()); ("download without attachments") to clear the database.

0
source

Source: https://habr.com/ru/post/1434942/


All Articles