Setting up PHPUnit with XAMPP
XAMPP is a great utility to get you started quickly with Apache, MySQL, and PHP. XAMPP have feature to test your PHP code use PHPUnit. Before you can use PHPUnit you must have PEAR as first installation. However the PEAR installation needed some additional work as explained below.
1. First get and install XAMPP
Now after the install, usually you’ll have your files under something like c:\xampp\php, etc. This works pretty well, but to get PHPUnit, you need PEAR which needs some additional install.
2. Get the latest PEAR update and run the PEAR installer:
download the file at http://pear.php.net/go-pear.phar and place it in your C:\xampp\php folder
cd \xampp\php php go-pear.phar
3. Change the location of your pear.ini (item#11) to C:\xampp\php – This is especially important on Windows 7 that protects the windows folder. If this is not changed your PEAR install will not be able to save its configuration files.
4. Run the C:\xampp\php\PEAR_ENV.reg file created to import your PEAR environment variable settings.
5. Log out of Windows and back in – This will load the new environment variables into memory (otherwise the old location for pear.ini will be used). Confirm your settings by running:
pear config-show
It should now read: C:\xampp\php\pear.ini
6. Install PHPUnit & Skeleton Generator through PEAR
pear config-set auto_discover 1 pear install pear.phpunit.de/PHPUnit pear install phpunit/PHPUnit_SkeletonGenerator pear install phpunit/PHPUnit_Selenium
7. Check your version of PHPUnit – It should be at least version 3.6.x
phpunit --version
You should also now have phpunit-skelgen.bat in the C:\xampp\php folder.
You can also testing your database code. You can visit here:
http://digitalsandwich.com/archives/63-phpunit-database-extension-dbunit-port.html
If you are trying to use Netbeans to do unit testing in PHP, then you should probably start at:
http://netbeans.org/kb/docs/php/phpunit.html#installing-phpunit
For installing Selenium in NetBeans:
1. Open Netbeans, choose from MenuBar Tools -> Plugins.
2. On Available Plugins choose Selenium Module for PHP and Selenium Server ([Optional] install, if your Selenium can’t run then you must install Selenium Server on NetBeans)
NB:
If you already install or have PHPUnit from somewhere else (not from xampp), never follow this instruction because it won’t work. If you want to follow this instruction, make sure your computer are clean from previous PHPUnit (registry too) and try it with newest XAMPP.
This settings are done with Windows 7 Prof 64-bit RAM and XAMPP v1.8.1 on “C:\”
For installing PHPUnit Selenium, better check your PHP version first, because it didn’t work twice on PHP v5.3, but its work with PHP v5.4