My WordPress TDD development setup - Mac version

Since I’ve had to undergo a clean system reinstall on my main working machine (a Mac) I thought I could use the occasion to show my current WordPress TDD setup and the guides I’ve followed to set it up.

Installing MAMP and PHP

Since I’m working locally on my themes and plugins I’m using MAMP to create local installations of WordPress: installing MAMP is as difficult as downloading it and installing it as any other Mac application.
MAMP comes bundled with PHP and since I’m using MAMP to serve the sites using its version of PHP throughout the system only makes sense. To do so OSX Terminal must be told to look into the right bin folder for php command. When launched OSX terminal will look into a file called ~/.bash_profile for any launch instructions, in this file I tell Terminal to look for MAMP’s version of php before looking for the system’s default one:

export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH

Where in place of php5.5.3 you might have any other PHP version that comes bundled with MAMP.
Quit Terminal, relaunch and enter the command:

php -v

to get PHP version. The reported version should be the one you specified in the path.

Installing pear

pear is a “PHP Extension and Application Repository” the name of which tells the tale. It does not come bundled with MAMP but if you have successfully installed PHP then installing pear is as simple as entering

wget http://pear.php.net/go-pear.phar php -d detect_unicode=0 go-pear.phar

To test that pear has been successfully installed run

pear

at the prompt.

Installing PHPUnit using pear

Following official site instructions if pear has been successfully installed then the simple commands:

pear config-set auto_discover 1 pear install pear.phpunit.de/PHPUnit

will do the trick. To test that PHPUnit has been successfully installed run:

phpunit

at the Terminal prompt.

Installing Firefox, Selenium IDE and PHPUnit

I did follow DragonBe’s instructions and will not repeat them.

Installing WordPress multisite using MAMP

Again I follow someone’s else instructions and will simply link them. The choice to test into a multisite WordPress environment is not mine but Pippins' as suggested in Apply Filter podcast and am taking it as an expert advice to follow. The logic behind this choice is that testing plugins or themes in a multisite environment makes them more robust and ready for a larger user base.

Setting up MAMP to use Dropbox

While setting MAMP to point to a Dropbox folder to use it for a virtual host is a matter of clicks setting MySQL to look for databases in Dropbox requires some steps as detailed in Simon Smith’s guide on the subject. I follow both guides to the letter and never had a problem.

Conclusion

While the above setup is not perfect it is now my foundation to work locally on themes and plugins for WordPress. I move the files and folders I’m working on into Dropbox to be able to access them from anywhere and to have the added security of an automated backup.