In the previous topic I discussed the use of PHPUnit for PHP programmers. Hope it has been of help to you. Today I would like to discuss the implementation part of it. As I said earlier, PHPUnit is an integral part of PHP testing. PHPUnit is very easy to use but prior to it, we need to know how to install it in the system.
There are some manual downloads available on Internet but I would suggest you go for the PEAR Installer which, you will find in http://pear.php.net. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped, with every release of PHP. However, the PEAR channel (pear.phpunit.de) which, is used to distribute PHPUnit, needs to be registered with the local PEAR environment. Let us have a look at the steps involved in the entire process.
Step 1: Go to command prompt and navigate to your directory where PEAR is installed. If it is installed properly, the pear command will run successfully. The moment it starts running successfully, you have to type-
pear channel-discover pear.phpunit.de
– and press ‘Enter’.
Step 2: Now the PEAR Installer can be used to install packages from the PHPUnit channel:
pear install phpunit/PHPUnit
This command will automatically install PHPUnit. After the installation you will find the PHPUnit source files inside your local PEAR directory.
Although using the PEAR Installer is the only supported way to install PHPUnit, you can also install PHPUnit manually. For manual installation, you can go to http://pear.phpunit.de/get/ and extract it to a directory that is listed in the include_path of your php.ini configuration file.
Now create your test suit!
Copy the whole PHPUnit folder and its associated files to your convenient location where you want to put your test classes used in the PHPUnit. You may face some path related problem but I feel you guys are intelligent enough to overcome those little problems.
I wouldn’t want them to misinterpret the fantasy check my essay vs.