phpunit require_once() error

2019-01-30 10:11发布

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?

17条回答
Animai°情兽
2楼-- · 2019-01-30 10:37

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"
查看更多
SAY GOODBYE
3楼-- · 2019-01-30 10:37

You can solve this issue by redefining the environment variables in PEAR. This is how I solved the problem and I used Ubuntu 12.10

http://rkrants.blogspot.in/2013/01/installing-phpunitpear-in-ubuntu-1210.html

In short it defines the paths and then reinstalls phpunit

查看更多
三岁会撩人
4楼-- · 2019-01-30 10:38

https://github.com/sebastianbergmann/php-code-coverage

sb@ubuntu ~ % pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded

sb@ubuntu ~ % pear channel-discover components.ez.no
Adding Channel "components.ez.no" succeeded
Discovery of channel "components.ez.no" succeeded

sb@vmware ~ % pear install phpunit/PHP_CodeCoverage
downloading PHP_CodeCoverage-0.9.0.tgz ...
Starting to download PHP_CodeCoverage-0.9.0.tgz (108,376 bytes)
.........................done: 108,376 bytes
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-0.9.0
查看更多
Fickle 薄情
5楼-- · 2019-01-30 10:39

I was having the same problem. Netbeans was reporting that the phpunit version was too old (which it wasn't). Running the phpunit script directly showed the above messages.

I solved it adding:

include_path=".:/usr/share/php"

To /etc/php5/cli/php.ini

Please NOTE that the php.ini file is the one for php CLI (command) not the php.ini used for apache!

查看更多
虎瘦雄心在
6楼-- · 2019-01-30 10:40

This is also what happens if you have an out-of-date or incomplete PHPUnit install. Please be aware that after you set up PEAR, you must add the PHPUnit.de channel in order to get an up-to-date package.

查看更多
登录 后发表回答