Install PHPUnit On Debian

php unit

First my Debian version is:

[root@www:~]# cat /proc/version
Linux version 2.6.32-pony6-3 (root@debian) (gcc version 4.4.6 (Debian 4.4.6-14) ) #1 SMP Tue Mar 13 07:31:44 PDT 2012

Per PHPUnit To install PHPUnit, using the following two command:

pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit

However, nothing is simple, you may see the error message, like

[root@www:~]# pear install pear.phpunit.de/PHPUnit
Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit requires PEAR Installer (version >= 1.9.4), installed version is 1.9.1
phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0, version <= 1.1.99) phpunit/File_Iterator requires PEAR Installer (version >= 1.9.2), installed version is 1.9.1
phpunit/Text_Template requires PEAR Installer (version >= 1.9.4), installed version is 1.9.1
phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.4), installed version is 1.9.1
phpunit/PHP_CodeCoverage requires package "phpunit/File_Iterator" (version >= 1.3.0)
phpunit/PHP_CodeCoverage requires package "phpunit/Text_Template" (version >= 1.1.1)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
phpunit/PHP_Timer requires PEAR Installer (version >= 1.9.2), installed version is 1.9.1
phpunit/PHPUnit_MockObject requires PEAR Installer (version >= 1.9.4), installed version is 1.9.1
phpunit/PHPUnit_MockObject requires package "phpunit/Text_Template" (version >= 1.1.1)
phpunit/PHP_TokenStream requires PEAR Installer (version >= 1.9.4), installed version is 1.9.1
No valid packages found
install failed

If you see this error, it means you need to upgrade your Pear. To upgrade Pear you can use the following commands,

pear upgrade

If you see the following result, that means you pear has been upgraded.

upgrade ok: channel://pear.php.net/Console_Getopt-1.3.1
upgrade ok: channel://pear.php.net/Structures_Graph-1.0.4
upgrade ok: channel://pear.php.net/Archive_Tar-1.3.11
upgrade ok: channel://pear.php.net/PEAR-1.9.4

Then you can try to install PHPUnit again.

pear install pear.phpunit.de/PHPUnit

If everything is good, then you should be able to run phpunit from your command line, if command is found, congratulations, you have installed phpunit.

Now you would need to learn how using phpunit, that is a hard part.

Leave a Reply

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