Setting up Symfony2 for Testing

Setting a Symfony2 project up for testing can be tricky, however in this short
guide I will show you how you are able to setup your project so you can spend
more time coding and less time trying to fix issues you run into while setting
up a testing environment.

One of the first steps you will need to do is setup your `test` environment in
symfony2. The way we are going to setup the environment is to use Doctrine ORM
and configure it to use SQLite for the database.

Start by adding a few lines to some of the configuration files.

{% highlight yaml %}
# app/config/parameters.yml
parameters:
database_driver: pdo_sqlite
database_path: “%kernel.root_dir%/data.db3”
{% endhighlight %}

This tells Doctrine to use SQLite and where it can find the database file.

{% highlight yaml %}
# app/config/config_test.yml
doctrine:
dbal:
path: “%database_path%”
{% endhighlight %}

You shouldn’t need to add anything else to the `config_test.yml` file since it
will import other configuration files which will be used to configure the rest
of doctrine. You can check your configuration by running `app/console
debug:config doctrine –env=test` and making sure everything looks as expected.

At this point running `phpunit -c app` will fail. There are just a few more
steps we need to complete before everything will work together.

Now we need to create a testing bootstrap file that PHPUnit will use, and then
update the `phpunit.xml.dist` file.

{% highlight php %}