How to install PHPUnit on Linux Mint 12 / Ubuntu 11.10

PHPUnit is a unit testing software framework for the programming language PHP; Created by Sebastian Bergmann, PHPUnit is one of thexUnit family of frameworks that originated with Kent Beck’s SUnit. PHPUnit was created with the view that the sooner you detect your code mistakes, the quicker you can fix them. Like all Unit testingframeworks PHPUnit uses assertions to verify that behaviour of the unit of code under test behaves as expected. PHPUnit doesn’t work with the normal installation procedure in Ubuntu and Linux Mint; it requires dependencies and can be installed by using PEAR package.

Install PHPUnit:

Let’s try to install with normal apt-get command

raj@GeekSIte ~ $ sudo apt-get install phpunit

Confirm the version of PHPUnit.

raj@GeekSIte:~$ phpunit --version
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38

From the above you can understand the issue, with the PEAR we can resolve the issue. Upgrade the PEAR if necessary.

raj@GeekSIte ~ $ sudo pear upgrade pear

Install the dependencies using PEAR package.

raj@GeekSIte ~ $ sudo pear channel-discover
raj@GeekSIte ~ $ sudo pear channel-discover
raj@GeekSIte ~ $ sudo pear channel-discover
raj@GeekSIte ~ $ sudo pear install --alldeps phpunit/PHPUnit

Verify that It Works!.

raj@GeekSIte ~ $ phpunit --version
PHPUnit 3.6.10 by Sebastian Bergmann.

That’s all!

linuxmintlinuxmint 12pearphpphpunitubuntuubuntu 11.04ubuntu 11.10
Comments (0)
Add Comment