Installing PHPUnit Test

guruwannabe
  13 years ago
  2

20110921 -- I have included the date in case you are reading this years later and this don't apply anymore :).

I am creating this as a mini-log that I hope to serve as a personal experience reminder and a share with others who might experience the same issue.

OS: Linux Mint 11 64bit

Pre-requisite: It is assumed that PEAR is already installed on your system. Perform Step (i) below to check.

Steps: Open a Terminal Shell and type:

i) pear

ii) sudo pear channel-discover pear.phpunit.de

iii) sudo pear channel-discover components.ez.no

iv) sudo pear channel-discover pear.symfony-project.com

v) sudo pear install phpunit/PHPUnit

The above outlined the normal procedural steps necessary to get PHPUnit installed on your system.

To check your PHPUnit installation type:

vi) phpunit

If installation is successful, you will see:

PHPUnit 3.5.15 by Sebastian Bergmann.

Usage: phpunit [switches] UnitTest [UnitTest.php]
       phpunit [switches]
.......... follow by a listing of options and what they do .......

However, if you see this error:

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


It could mean that you might need to upgrade your version of PEAR before PHPUnit can be properly installed. Most probably, you have earlier encountered some error while installing PHPUnit using the above procedures.

If you saw the following error earlier in step (v):

a) phpunit/PHPUnit requires PEAR Installer (version >= 1.9.3), installed version is 1.9.1
b) phpunit/DbUnit requires PEAR Installer (version >= 1.9.2), installed version is 1.9.1
c) phpunit/File_Iterator requires PEAR Installer (version >= 1.9.2), installed version is 1.9.1
d) phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.2), installed version is 1.9.1
e) phpunit/PHP_CodeCoverage requires package "phpunit/File_Iterator" (version >= 1.2.2)
 

Perform the following to upgrade PEAR and re-install PHPUnit

i) sudo pear update-channels

ii) sudo pear upgrade-all

Note: My PEAR 1.9.1 was upgraded to 1.9.4; your version might be different.

iii) sudo pear install phpunit/PHPUnit

When the installation ends successfully, you will see the following at the end of the report:

install ok: channel://pear.phpunit.de/DbUnit-1.0.3
install ok: channel://pear.phpunit.de/File_Iterator-1.2.6
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.2
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.9
install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.0.3
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.0.5
install ok: channel://pear.phpunit.de/PHPUnit-3.5.15

To test your PHPUnit Test installation:

iv) phpunit

That's all folks, hope it helps

Bob WONG

Comments
dudan 12 years ago

Thank you so much for this, been battling with this problem for sometime now


guruwannabe 12 years ago

Guys,
Thanks for the comments and encouragement.
@Alexio: Thanks for the Video link. I am also thinking of making some video tutorial. Is that an official linuxmint website or is there another?


trollboy 13 years ago

PHPUnit is a very useful testing framework. Nice tutorial.


Alexio 13 years ago

This tutorial is useful after you learn How to install Apache and PEAR on Linux Mint - a video tutorial available on the Linux Mint Community Videos website.


blueXrider 13 years ago

Score: 0
votes: 6
Format: Article
Created: 3 days ago.
Last edited: 3 days ago.
Reviewed: 3 days ago by oscar799.

Fix the Read 0 times.