Isolate your Symfony2 Unit Tests
This blog post describes how to tear down & create your database at the start of each test run, which is a good way to isolate your tests from your dev environment
Simply replace your database name in config_test.yml:
doctrine:
dbal:
dbname: %database_name%_test
and in your bootstrap.php you can drop & create the DB, run your database migrations & load any fixtures you might want.
You can see my bootstrap.php here
You could of course fully isolate your tests by extending PHPUnitFrameworkTestCase & add the same methods to setUp & tearDown, but with all the different types of test cases that Symfony provides, that can be a little time consuming.
Written by Stuart Grimshaw
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#