Few useful web applications have a trivial design; most have a set of “moving parts” that are integrated to form the end product. As the functionality and features of a product change, so does its definition of intended or correct behavior. The purpose of automated testing is to assure that an application’s intended behavior and its actual behavior are consistent over its lifetime.
— PHP Master: Write Cutting-edge Code by Lorna Mitchell, Davey Shafik, and Matthew Turland
So with that said here is a short tutorial on installing phpUnit with MAMP.
Step 1: Install MAMP. The downloads and instructions are here http://www.mamp.info/en/index.html
Step 2: Open up terminal and go to the pear directory within your mamp installation. You specific path may differ slightly.
Step 3: Use either sudo each time or enter the root prompt with sudo su.
Step 4: Update Pear
pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com pear channel-update pear.php.net pear upgrade pear
Step 4: Install PHPUnit
pear install phpunit/PHPUnit
During the process you get the following error:
Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050 ERROR: The default config file is not a valid config file or is corrupted.
To fix, edit /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
Check your installation
phpunit --version # PHPUnit 3.5.15 by Sebastian Bergmann.
There you have it, happy unit testing.