“Sebastian Bergmann”:http://sebastian-bergmann.de/ and his contributors are proud to announce the immediate availability of “PHPUnit 3”:http://www.phpunit.de/. This release is a major improvement to the popular open source testing solution for “PHP”:http://www.php.net/ applications. It includes new features and bug fixes. Further details about this release can be found in the “ChangeLog”:http://www.phpunit.de/wiki/ChangeLog.
h2. New Features
PHPUnit 3 introduces a number of new features that make it easier to use and more versatile than previous versions.
h3. 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”:http://www.phpunit.de/pocket_guide/3.0/en/mock-objects.html and Stubs provide the answer to these and other
h3. Selenium Integration
PHPUnit 3 integrates with “Selenium RC”:http://www.phpunit.de/pocket_guide/3.0/en/selenium.html 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).
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”:http://www.phpunit.de/pocket_guide/3.0/en/code-coverage-analysis.html .
PHPUnit 3 features an improved report generator that provides detailed
code-coverage information for tests run.
PHPUnit should be installed using the PEAR Installer.
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.
h2. 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.
h2. About PHPUnit
In the last decade, PHP has developed from a niche language for adding dynamic functionality to small websites to a powerful tool making strong inroads into large-scale Web systems. Critical business logic like this needs to work correctly. But how do you ensure that it does?
You test it, of course.
To make code testing viable, good tool support is needed. This is where PHPUnit comes into play. It is a member of the xUnit family of testing frameworks and provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results.
h2. About Sebastian Bergmann
Sebastian Bergmann is a long-time contributor to various PHP projects, including PHP itself. He is currently working at eZ systems AS in Skien, Norway on the Workflow Management component for the eZ platform. As the developer of PHPUnit, he also helps with testing the eZ components. In his free time he likes to hack on Open Source software and to take photographs, preferably while traveling the world.