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条回答
爷的心禁止访问
2楼-- · 2019-01-30 10:18

I had the same issue with Windows 8 Similar to the top answer, I needed to start the command line, however make sure to run cmd.exe as administrator. Then the two commands

pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
查看更多
再贱就再见
3楼-- · 2019-01-30 10:20

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
查看更多
欢心
4楼-- · 2019-01-30 10:20

Ubuntu 12.04:

sudo pear channel-discover pear.symfony.com
sudo pear install --alldeps phpunit/PHPUnit
查看更多
家丑人穷心不美
5楼-- · 2019-01-30 10:24

In my case, I solved it by adding /usr/share/php/PEAR to the include_path.

I'm using Ubuntu 10.04.2.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-30 10:24

My original problem was I could not get the command line version of php (yum install php or yum install php-cli) to upgrade to => php5.2.7 I was stuck on 5.1 version

I had already compiled php 5.3.3 for use with apache. So I setup a symbolic link from /usr/bin/php (the command line default) to my compiled version in /var/php5/bin/php to get the command line php reporting 5.3.3

Then I refollowed the pear install steps for phpunit

But it still needed the code coverage stuff when I ran phpunit.

So I hunted code coverage down under /var/php5/lib/php/PHP/CodeCoverage and added that to the include path in php.ini include_path=".:/var/php5/lib/php/"

Make sure to add it to the include path without /PHP because phpunit starts at PHP/ (notice caps) looking for Code Coverage Failed opening required 'PHP/CodeCoverage/Filter.php'

查看更多
ゆ 、 Hurt°
7楼-- · 2019-01-30 10:24

For me dividing test's in multiple batches helped.

查看更多
登录 后发表回答