Installing PHPUnit in Ubuntu 11.10

As per MediaWIki Manual:PHP unit testing/Installing PHPUnit there’s a known issue which is basically, the Apt package for Ubuntu 11.10, 12.04 is broken. Now, it has been suggested to instal by hand using the exact commands in the #Using PEAR section, as it works!

But seriously, it was not working, for me at least. Following the Pear instructions given , I wasn’t seeing any specific error at times. But commands like ‘which phpunit’ or ‘phpunit –version’ would generate errors. After going through links like http://stackoverflow.com/questions/1528717/phpunit-require-once-error and the ubuntu forum. I realized I should be installing PHP_CodeCoverage. Which after done, the error: (When asked for phpunit –version)

Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39

After several hours of investigation, I finally realized the trouble was in the pear package, it was most definitely not configured properly.

Configuring PEAR package:

sudo pear config-set bin_dir /usr/bin 

sudo pear config-set doc_dir /usr/share/php/doc 

sudo pear config-set php_dir /usr/share/php 

sudo pear config-set cfg_dir /usr/share/php/cfg

sudo pear config-set data_dir /usr/share/php/data


sudo pear config-set test_dir /usr/share/php/test

And then the following

$ sudo pear uninstall phpunit/PHPUnit

 
$ sudo pear install phpunit/PHPUnit


And here's the successful installation test :

$ which phpunit
/some/path/to/bin/phpunit 
$ phpunit --version
PHPUnit A.B.C by Sebastian Bergmann.


Yeah.. so this is it! :-)


Leave a Reply

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