Mehic.info

Installing PHPUnit On Windows

Assuming you already have PHP and MySQL installed, here’s the steps you need to take. Install PEAR, a dependency for PHPUnit:

  • Visit http://pear.php.net/go-pear.phar in your browser and save the file into your PHP directory. This is the folder where you can find php.exe.
  • Open an administrator command prompt. On Vista or Windows 7, hit your Windows key, type “cmd”, right-click the resulting “cmd.exe” search result, and select “Run as administrator”. Navigate to the folder where you have PHP installed, the same folder where you saved the file in the previous step.

Type the following command to execute the file you just downloaded:

php go-pear.phar
  • Press Enter to accept the default when it asks you “Are you installing a system-wide PEAR or a local copy?”
  • Press Enter again to accept the file layout.
  • Press Enter to finish.

Run the following commands (they may take a while to update, be patient):

pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels
pear channel-discover pear.symfony.com
pear install pear.symfony.com/Yaml

To install PHPUnit, run

pear install --alldeps --force phpunit/PHPUnit

To test that PHPUnit was successfully installed, run

phpunit -v

If you have some problems with cache or channels try following :

pear update-channels
pear clear-cache

If you already have installed PHPUnit for Zend Framework 1.1. it is advised to use PHPUnit 3.5., so downgrade your PHPUnit with:

Firstly, uninstall PHPUnit 3.6 and all of it’s dependencies.

sudo pear uninstall phpunit/PHPUnit
sudo pear uninstall phpunit/DbUnit
sudo pear uninstall phpunit/PHP_CodeCoverage
sudo pear uninstall phpunit/File_Iterator
sudo pear uninstall phpunit/Text_Template
sudo pear uninstall phpunit/PHP_Timer
sudo pear uninstall phpunit/PHPUnit_MockObject
sudo pear uninstall phpunit/PHPUnit_Selenium
sudo pear uninstall pear.symfony-project.com/YAML

And then install these specific versions of each dependency, in this order, installing PHPUnit-3.5.15 last.

sudo pear install pear.symfony-project.com/YAML-1.0.2
sudo pear install phpunit/PHPUnit_Selenium-1.0.1
sudo pear install phpunit/PHPUnit_MockObject-1.0.3
sudo pear install phpunit/PHP_Timer-1.0.0
sudo pear install phpunit/File_Iterator-1.2.3
sudo pear install phpunit/PHP_CodeCoverage-1.0.2
sudo pear install phpunit/Text_Template-1.0.0
sudo pear install phpunit/DbUnit-1.0.0
sudo pear install phpunit/PHPUnit-3.5.15