Test Driven Development and xUnit seem to be popular among many of the professional and very public programmers, so I thought I might like to give it a whirl and see if I can improve the flexibility of my source code and better decouple objects. Unfortunately, I use WAMPServer on Windows as a development server while at work so directions for installing PHP related plugins/PEAR aren’t exactly identical. (Usually, I can figure it out fairly quickly.)
Installing WAMPServer is fairly quick and well documented online, so I won’t cover it specifically although I will mention I am using WAMPServer v2 at time of this writing. I will also assume that you have used the default file paths of “C:wamp” and “C:wampwww”
Steps to installing PHPUnit:
- Install PEAR if you haven’t already by opening up a new command window and entering the following commands
- Press enter when the list of directories appears
- When asked if you want PHP.ini to be modified press Y and then enter.
- You will be told the include path is updated. Press enter.
- You be will be told PEAR_ENV.reg has been created.
- Pear is installed, but it isn’t the newest version of the updater, so we should update because PHPUnit requires at least PEAR Updater 1.8.1
- Thankfully, we are nearly done our journey. We simply need to add a channel to PEAR and then we can install!
pear channel-discover pear.phpunit.de
pear install –alldeps phpunit/PHPUnit
Good luck testing and keep checking back to see how to test!
Author: Brian Cline