Today I had a similar problem, and I think I found a good solution.
- Create a copy of your database (also create a new empty database).
- Modify the config_test.yml file to change the database name.
An example of my test configuration (may differ depending on whether you have several db-s, etc.)
doctrine: dbal: dbname: test_db
- Update your database to display objects in your application by calling
php app/console doctrine:schema:update --force --env=test (required if you just created a new db, and also every time you change the model applications).
Your application should now use the test database during unit tests. NB! Be sure to back up your database before messing with the active database.
However, as mentioned above, these are no longer Unit Tests, but integration tests.
source share