Before submitting a :doc:`patch <patches>` for inclusion, you need to run the Symfony2 test suite to check that you have not broken anything.
To run the Symfony2 test suite, install PHPUnit 3.5.0 or later first:
$ pear channel-discover pear.phpunit.de
$ pear channel-discover components.ez.no
$ pear channel-discover pear.symfony-project.com
$ pear install phpunit/PHPUnit
To run the entire test suite, including tests that depend on external dependencies, Symfony2 needs to be able to autoload them. By default, they are autoloaded from vendor/ under the main root directory (see autoload.php.dist).
The test suite need the following third-party libraries:
- Doctrine
- Doctrine Migrations
- Swiftmailer
- Twig
To install them all, run the vendors script:
$ php vendors install
Note
Note that the script takes some time to finish.
After installation, you can update the vendors to their latest version with the follow command:
$ php vendors update
First, update the vendors (see above).
Then, run the test suite from the Symfony2 root directory with the following command:
$ phpunit
The output should display OK. If not, you need to figure out what's going on and if the tests are broken because of your modifications.
Tip
Run the test suite before applying your modifications to check that they run fine on your configuration.
If you add a new feature, you also need to check the code coverage by using the coverage-html option:
$ phpunit --coverage-html=cov/
Check the code coverage by opening the generated cov/index.html page in a browser.
Tip
The code coverage only works if you have XDebug enabled and all dependencies installed.