Symfony
sponsored by SensioLabs
Menu
  • About
  • Documentation
  • Screencasts
  • Cloud
  • Certification
  • Community
  • Businesses
  • News
  • Download
  1. Home
  2. Documentation
  3. Contributing
  4. Code
  5. Running Symfony2 Tests
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud
Search by Algolia

Table of Contents

  • PHPUnit
  • Dependencies (optional)
  • Running
  • Code Coverage

Running Symfony2 Tests

Edit this page

Warning: You are browsing the documentation for Symfony 2.0, which is no longer maintained.

Read the updated version of this page for Symfony 6.2 (the current stable version).

Running Symfony2 Tests

Before submitting a patch for inclusion, you need to run the Symfony2 test suite to check that you have not broken anything.

PHPUnit

To run the Symfony2 test suite, install PHPUnit 3.5.11 or later first:

1
2
$ pear config-set auto_discover 1
$ pear install pear.phpunit.de/PHPUnit

Dependencies (optional)

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 needs the following third-party libraries:

  • Doctrine
  • Swiftmailer
  • Twig
  • Monolog

To install them all, run the `vendors` script:

1
$ php vendors.php 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:

1
$ php vendors.php update

Running

First, update the vendors (see above).

Then, run the test suite from the Symfony2 root directory with the following command:

1
$ 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

If you want to test a single component type its path after the `phpunit` command, e.g.:

1
$ phpunit src/Symfony/Component/Finder/

Tip

Run the test suite before applying your modifications to check that they run fine on your configuration.

Code Coverage

If you add a new feature, you also need to check the code coverage by using the `coverage-html` option:

1
$ 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.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
We stand with Ukraine.
Version:
Symfony Code Performance Profiling

Symfony Code Performance Profiling

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

Avatar of Joel Lusavuvu, a Symfony contributor

Thanks Joel Lusavuvu (@enigma97) for being a Symfony contributor

2 commits • 790 lines changed

View all contributors that help us make Symfony

Become a Symfony contributor

Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

Learn how to contribute

Symfony™ is a trademark of Symfony SAS. All rights reserved.

  • What is Symfony?
    • Symfony at a Glance
    • Symfony Components
    • Case Studies
    • Symfony Releases
    • Security Policy
    • Logo & Screenshots
    • Trademark & Licenses
    • symfony1 Legacy
  • Learn Symfony
    • Symfony Docs
    • Symfony Book
    • Reference
    • Bundles
    • Best Practices
    • Training
    • eLearning Platform
    • Certification
  • Screencasts
    • Learn Symfony
    • Learn PHP
    • Learn JavaScript
    • Learn Drupal
    • Learn RESTful APIs
  • Community
    • SymfonyConnect
    • Support
    • How to be Involved
    • Code of Conduct
    • Events & Meetups
    • Projects using Symfony
    • Downloads Stats
    • Contributors
    • Backers
  • Blog
    • Events & Meetups
    • A week of symfony
    • Case studies
    • Cloud
    • Community
    • Conferences
    • Diversity
    • Documentation
    • Living on the edge
    • Releases
    • Security Advisories
    • SymfonyInsight
    • Twig
    • SensioLabs
  • Services
    • SensioLabs services
    • Train developers
    • Manage your project quality
    • Improve your project performance
    • Host Symfony projects
    Deployed on
Follow Symfony
Search by Algolia