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.
Let’s try to install with normal apt-get command
[email protected] ~ $ sudo apt-get install phpunit
Confirm the version of PHPUnit.
[email protected]:~$ 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.
[email protected] ~ $ sudo pear upgrade pear
Install the dependencies using PEAR package.
[email protected] ~ $ sudo pear channel-discover pear.phpunit.de [email protected] ~ $ sudo pear channel-discover components.ez.no [email protected] ~ $ sudo pear channel-discover pear.symfony-project.com [email protected] ~ $ sudo pear install --alldeps phpunit/PHPUnit
Verify that It Works!.
[email protected] ~ $ phpunit --version PHPUnit 3.6.10 by Sebastian Bergmann.