Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database cleaning in Symfony2 tests

Is there a standard way of cleaning your database before (or after) each test when you're testing with Symfony2/PHPUnit? There seems to be a standard, obvious way to do this in Rails but I haven't found an analog in the Symfony community.

like image 734
Jason Swett Avatar asked Nov 04 '22 15:11

Jason Swett


1 Answers

You can either purge the tables with Doctrine's data purger or rebuild the schema before every test.

Purger is part of data-fixtures package: https://github.com/doctrine/data-fixtures

I once wrote a KernelAwareTest which rebuilds the schema before every test: https://gist.github.com/1319290

like image 156
Jakub Zalas Avatar answered Nov 15 '22 10:11

Jakub Zalas