PHPUnit 3.0

Sebastian Bergmann and his contributors are proud to announce the immediate availability of PHPUnit 3. This release is a major improvement to the popular open source testing solution for PHP applications. It includes new features and bug fixes. Further details about this release can be found in the ChangeLog. New Features PHPUnit 3 introduces a number of new features that make it easier to use and more versatile than previous versions.

  • Mock Objects How can you test that a method works correctly when it is called from another method? How can you isolate your tests from external influences? Mock Objects and Stubs provide the answer to these and other questions.
  • Selenium Integration PHPUnit 3 integrates with Selenium RC to support both acceptance testing (by performing higher-level tests on the integrated system instead of just testing each unit of the system independently) and browser compatibility testing (by testing the web application on different operating systems and browsers).
  • Code-Coverage How do you test your tests? How do you find code that is not yet tested -- or, in other words, not yet covered by a test? How do you measure testing completeness? All these questions are answered by a practice called Code-Coverage Analysis. PHPUnit 3 features an improved report generator that provides detailed code-coverage information for tests run.
Installation The PEAR channel (pear.phpunit.de) that is used to distribute PHPUnit needs to be registered with the local PEAR environment:
pear channel-discover pear.phpunit.de
This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel:
pear install phpunit/PHPUnit
Previous installations of the PHPUnit and PHPUnit2 packages from the pear.php.net channel have to be uninstalled since PHPUnit is no longer hosted on PEAR. Upgrading from PHPUnit 2.3 PHPUnit 3 is backwards compatible with PHPUnit 2.3. Please note that in PHPUnit versions 2.0-2.3 the class names were prefixed with PHPUnit2_ instead of PHPUnit_. Existing test cases will still work with PHPUnit version 3.0, but it is highly recommended to update them to use the new class names. Documentation The PHPUnit Pocket Guide has been updated for PHPUnit 3 (English, Japanese). Please note that documenting PHPUnit is an ongoing effort. You can expect additions and improvements to the PHPUnit Pocket Guide in the future.