Monday, September 10

Netbeans and PHPUnit again ...

Well in Ubuntu 12.04 the steps to install PHPUnit had changed a bit ...

Install the latest PHPUnit with ant

I got this instructions from a blog, but searching I cannot find which one ... anyway, the last steps seems redundant but this will ensure that the correct version of PHPUnit is installed

$ sudo apt-get install ant php5-dev php-pear
$ sudo pear channel-discover
$ sudo pear channel-discover
$ sudo pear channel-discover
$ sudo pear update-channels
$ sudo pear upgrade-all
$ sudo pear install --alldeps phpunit/PHPUnit
$ sudo pear install PhpDocumentor

Now we need to install PHPUnit from the repositories, this will create the phpunit file in /usr/bin, I'm sure there is a better way for this but I did't had the time to check

$ sudo apt-get install phpunit

The last step broke phpunit, so we need to reinstall it ...

$ sudo pear uninstall phpunit/PHPUnit
$ sudo pear install phpunit/PHPUnit 

Make work PHPUnit with Netbeans again

Open the Netbeans preferences, go to the "PHP" tab and in that tab select the "Unit Testing" tab
Type /usr/bin/phpunit into the first box, click "OK"

Now at your project right click the "Include Path" and select the "properties"

Click "Add Folder .,." and select the folder /usr/share/php/PHPUnit Click "OK"

Now you will have the autocomplete running for abstract classes, methods, asserts, etc.

As always pressing alt + F6 the unit tests will run in Netbeans providing a useful output and code coverage