10
votes

I am trying to get phpUnit running on a centos running plesk pannel.

I have installed phpunit successfully.

Package            Version State
File_Iterator      1.3.1   stable
PHPUnit            3.6.10  stable
PHPUnit_MockObject 1.1.1   stable
PHP_CodeCoverage   1.1.2   stable
PHP_Invoker        1.1.0   stable
PHP_Timer          1.0.2   stable
PHP_TokenStream    1.1.3   stable
Text_Template      1.1.1   stable

however whenever i run the phpunit command from the shell i get the following error:

PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /usr/share/pear/PHPUnit/Autoload.php on line 45
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:') in /usr/share/pear/PHPUnit/Autoload.php on line 45

Has anyone a clue how to solve the problem?

5
What does pear info phpunit/File_Iterator say? It looks like it didn't get installed, but PHPUnit depends on it. - David Harkness
On my Mac OSX 10.7.1 in /etc/php.ini the include_path was set to /user/lib/php/pear instead of /usr/lib/php/pear It is surprising how long you can stare at something and not notice the extra e ! - Nick T
I do believe this is the correct answer to any questions relating to php unit File_Iterator. github.com/sebastianbergmann/php-file-iterator - Louie Miranda

5 Answers

6
votes

I tried a billion different articles and the commands that finally fixed this issue for me were the following:

sudo pear channel-discover pear.phpunit.de
sudo pear install --alldeps --force phpunit/phpunit

Then, when I ran phpunit, I didn't get the errors and it ran successfully.

4
votes

I'm not sure how this translates for plesk, but the problem is the include_path specified in your php.ini file is set to just the current directory. Verify where your php.ini file is by running the following from the command line...

% php --info

...and look for the following entries...

Configuration File (php.ini) Path => /etc

Loaded Configuration File => /etc/php.ini

In this case, edit /etc/php.ini and look for the for include_path. In my case I need to set it as follows...

include_path = ".:/opt/php-5.3.14/lib/php/pear"
2
votes

Your include path must include the directory where PEAR installs all those packages. Add /usr/share/pear to your include path in php.ini--probably /etc/php5/cli/php.ini.

2
votes

On the Ubuntu (10.04) I also added /usr/share/php to the /etc/php5/cli/php.ini.

0
votes

In Fedora release 19 it has been solved by adding the /usr/share/pear/ path to the include_path of /etc/php.ini