Sunday, August 12, 2007

PHPUnit

It appears PHP has standardized on unit testing methods. It appears many people use the package PHPUnit. However for some reason it doesn't come preinstalled or in the standard PEAR channels. Here are the instructions:

Installation
The PEAR channel (pear.phpunit.de) that is used to distribute PHPUnit needs to be registered with the local PEAR environment:

pear channel-discover pear.phpunit.de

This has to be done only once. Now the PEAR Installer can be used to install packages from the PHPUnit channel:

pear install phpunit/PHPUnit

Previous installations of the PHPUnit and PHPUnit2 packages from the pear.php.net channel have to be uninstalled since PHPUnit is no longer hosted on PEAR.


Unfortunately that doesn't work. I get the error

Aug 12, 2007(10:13:15) [root@~]> pear channel-discover pear.phpunit.de
Channel "pear.phpunit.de" is already initialized
Aug 12, 2007(10:14:49) [root@~]> pear install phpunit/PHPUnit
phpunit/PHPUnit can optionally use PHP extension "pdo_mysql"
phpunit/PHPUnit requires PHP extension "xdebug" (version >= 2.0.0), installed version is 2.0.0RC4
No valid packages found
install failed
Aug 12, 2007(10:14:58) [root@~]>

Now if you'll notice the author's website appears to take feedback. The keyword is appear. It's currently busted and only lets you preview your posts. I think this package and his website are perfect examples of how bad the PHP support is. The ideas are great. The implementation is way behind...

Here's a tip for the smuck, err, Sebastian Bergmann. He should start testing his work with automated test tools. Similar to the ones he develops!

2 comments:

. said...

I had to reinstall ubuntu from scratch, then reinstall my environment, then install PHPUnit from scratch.

Basically PEAR is a POS. So buggy that you must always be prepared to reinstall your OS.

On the positive side I made some scripts so new ubuntu installs should go very smoothly. Fortunately linux makes the whole install process scriptable.

akky said...

the problem here is that the PHPUnit package requires xdebug 2.0.0 or more but the current latest xdebug version is before that (2.0.0RC4).

one solution is to add "--force" option when you install PHPUnit, such like

> pear install --force phpunit/PHPUnit

it worked on my environment. hope it helps.