I recently installed phpunit on my server via the pear installer.

When I go to run a test I get the following error:

PHP Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 44

PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Filter.php' (include_path='.:/usr/bin/php') in /usr/bin/phpunit on line 44

After doing some searching, I tried making some modifications to the include_path in my php.ini file on the server. But that hasn't done a thing.

Any idea what might be causing this?


Solution 1:

UPDATE: As of 2013 November and Ubuntu 12.04 these 2 commands should suffice:

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

The following is an older answer. It's a known problem , although almost a year and a half had passed. Read about it here

The code coverage must be installed in order for phpunit to work properly

What you need to do is covered here:

code coverage installation through PEAR

Basically you have to type (with sudo if you don't have permissions, taken that phpunit is already installed):

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear install phpunit/PHP_CodeCoverage

Solution 2:

I had this problem on OS X. Fixed it with the following commands which force all the php dependencies to be reinstalled, which included a couple of packages from other channels that were not already configured:

sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear install --alldeps phpunit/PHPUnit

Solution 3:

https://bugs.launchpad.net/ubuntu/+source/phpunit/+bug/701544

and specially this comment for ubuntu 11.04 and may be for some others too

even though i did ths steps as recommended above, i didn't get it to work but after i upgraded pear from 1.9.1 to 1.9.2 it's working perfectly just do this

speshu@speshu-laptop:~$ sudo pear upgrade pear

   downloading PEAR-1.9.2.tgz ...
   Starting to download PEAR-1.9.2.tgz (295,120 bytes)
    .....................................................done: 295,120 bytes
    upgrade ok: channel://pear.php.net/PEAR-1.9.2
    PEAR: Optional feature webinstaller available (PEAR's web-based installer)
    PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
    PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
    PEAR: To install optional features use "pear install pear/PEAR#featurename"

Solution 4:

If it is the first time you are using PEAR, perhaps you have not configured the include path right. Take a look at the appropriate section in the PEAR manual.