From the Jobeet tutorial provided in Symfony website, I found out that I can load fixtures data each time I run unit test by using this script:
Doctrine_Core::loadData(sfConfig::get('sf_test_dir').'/fixtures');
However, I want to delete and reload all records from database each time I run a unit test. Currently, I’m doing this manually (Run symfony doctrine:build –all before each test). Can someone provided me a correct way to do this?
I use the following in my test/bootstrap/unit.php file at the end:
before loading the fixtures in. This works nicely for me, although it can get slow if you have a large schema and lots of fixtures. There’s some tips over on the Web Mozarts blog about writing efficient tests, and there’s a tip about using an sqlite in-memory database to speed it up.