PHPUnit is a powerful unit testing framework written in and for PHP. Rather than testing everything as a whole the idea behind PHPUnit is to test that everything works as it is expected to work before it is integrated into the rest of the program. In this way problems are found earlier rather than later and this makes fixing them a lot easier. With tests written for every small component of the program it is then possible to test the whole thing by running all of the tests at once. It is also possible to automate PHPUnit so that everything about a program is tested before it is built. If any tests fail then the build is stopped.
The best way to install PHPUnit is to use the PEAR installer. To install PHPUnit you first need to add the correct channel so that PEAR can find PHPUnit easily. You do this by typing the following into the command line.
pear channel-discover pear.phpunit.de
You can now install PHPUnit by using the following command.
pear install phpunit/PHPUnit
You can now test your install by trying to run PHPUni through the command line.
phpunit
If properly installed this command will print out usage and parameter information for PHPUnit.
You can see which version of PHPUnit is installed by using the --version parameter.
phpunit --version
For more information about PHPUnit take a look at the PHPUnit website.
Comments
phpunit/PHPUnit requires PEAR Installer (version >= 1.8.1), installed version is 1.7.2You will therefore need to upgrade your copy of PEAR. To do this just type:
pear upgrade-allInto the command line and PEAR will update itself. You can now proceed with installing PHPUnit!