PHPUnit Installation Tips regarding tests in Zend Framework

Hi there, I spent quite a bit of time trying to figure out how to install PHPUnit and run tests with it. All the buzz comes from the fact that XAMPP can contain PHPUnit in its php\pear folder.  First I would recommend to uninstall the PHPUnit under your PEAR folder, so open command prompt from your XAMPP control panel and run:


1) pear uninstall phpunit/PHPUnit If you do not perform this action first, you will end up with a message complaining about your PHPUnit version : You have installed PHPUnit via PEAR. This installation method is no longer supported and will be shut down no later than December, 31 2014.

2) When you install Zend Framework (see post in my blog for further info) you have a composer.json file. Append the following line inside this ,json file:

"phpunit/phpunit": "4.1.*"

PHPUnit will be installed into your project after you have run the three commands given in my previous post:

php composer.phar self-update

php composer.phar install

php composer.phar update

After you run these commands you should have a folder with the dev-master files required for phpunit inside your vendor/phpunit/phpunit folder. It actually downloads the package into your Zend Framework application.

3) Next thing you have to do is download phpunit.phar . Go to your browser and type

Download the file and insert it into you phpunit test folder.

4) Navigate to your phpunit test folder and run from your command prompt window you previously opened:

phpunit.phar --version to make sure you got the most updated phpunit version.

5) Finally run a phpunit test and see the results you get.

Leave a comment

Your email address will not be published. Required fields are marked *