PHPUnit
The first thing is to download and extract
PHPUnit, download the file, unzip it and place the resulting folder in
1 | C:\wamp\bin\php\php5.2.9-2\ |
(I renamed the folder from PHPUnit-3.5.4 to phpunit but its up to you. You can also put the folder anywhere you want, so long as you amend the include path instruction below).
PHP.ini
With the PHPUnit files extracted, we need to alter our php.ini file to have an include path of our PHPUnit directory, add the following line to the appropriate section of the php.ini file.
1 | include_path = "C:\wamp\bin\php\php5.2.9-2\phpunit" |
Dependancies
Because I didn't/couldn't/wouldn't install this through PEAR, there were quite alot of dependancies missing, which was frustrating considering the manual installation instructions didn't mention this. I also found, that these dependancies had to be extracted to the (root) phpunit folder, and not the PHPUnit folder within there (which is where I'd initially put them - to a further series of errors!). Download the following dependancies, and extract them to the root phpunit folder (i.e. C:\wamp\bin\php\php5.2.9-2\phpunit).
- PHP/CodeCoverage (copy the PHP folder and its contents)
- PHP/Timer (copy the PHP folder and its contents (don't override the PHP folder from the previous dependancy))
- PHP/TokenStream (copy the PHP folder and its contents (don't override the PHP folder from the previous dependancies))
- Text/Template (copy the Text folder and its contents)
- File/Iterator (copy the File folder and its contents)
The bat (cave) file
Since we are running on Windows, to run PHPUnit, we can't simply rename phpunit.php to phpunit and run it (as per the instructions), we instead run the phpunit.bat file. The bat file in turn runs the PHP executable, and opens the phpunit.php file with it.
Open the phpunit.bat file, and replace its contents with the following (replacing paths to php.exe and phpunit.php with your own systems paths).
1 | C:\wamp\bin\php\php5.2.9-2\php.exe -d safe_mode=Off "C:\wamp\bin\php\php5.2.9-2\phpunit\phpunit.php" %* |
phpunit.php
Within the phpunit.php file you need to replace @php_bim@ with the path to your php directory (as per the documentation)
1 | C:\wamp\bin\php\php5.2.9-2 |
Running PHPUnit
Now simply open the command prompt, browse to your phpunit folder, and run phpunit followed by the file path of your tests.
Reference:
http://www.michaelpeacock.co.uk/blog/entry/phpunit-on-wamp
No comments:
Post a Comment