[PHPUnit] Failed opening required autoload.php error

After a re-installation of the operating system Ubuntu 12.04, I got a problem by installing/using PHPUnit, this maybe not the same as your case, but I posted it just for sharing, I hope that could help.

Before all, I just want to remind that Using the PEAR Installer to install PHPUnit is no longer supported, more info in pear.phpunit.de and github.

The way that I installed the phpunit is like this:

sudo apt-get install libcurl3 libcurl4-gnutls-dev libmagic-dev
sudo pecl install pecl_http
sudo pear upgrade PEAR
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony.com
sudo pear upgrade PEAR
sudo pear install pear.symfony.com/Yaml
sudo pear config-set auto_discover 1
sudo pear install --alldeps pear.phpunit.de/PHPUnit
sudo pear install -a phpunit/Dbunit
sudo pear install phpunit/PHPUnit_Selenium
sudo pear install phpunit/PHPUnit_Story

By when I try to launch the test, I got an error:

PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in

The first thing that I thought was that PHPUnit was not well included in php’s configuration file, such as php.ini. After some search, I found the comment in stack overflow. But it doesn’t work.

With the help of Thierry, we found that the version of PHPUnit installed is 4.0.17 which is a little bit different from our current version, and that’s why we can’t find the Autoload.php in /usr/share/php/PHPUnit.

To solve the problem, we just re-install the PHPUnit by indicating the exact version that we want, the commands will be almost the same(Sorry, I didn’t found where to change text color in wordpress source code, so… it’s line 10 that I changed 😦 ):

sudo apt-get install libcurl3 libcurl4-gnutls-dev libmagic-dev
sudo pecl install pecl_http
sudo pear upgrade PEAR
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony.com
sudo pear upgrade PEAR
sudo pear install pear.symfony.com/Yaml
sudo pear config-set auto_discover 1
sudo pear install --alldeps pear.phpunit.de/PHPUnit-TheVersionYouWant
sudo pear install -a phpunit/Dbunit
sudo pear install phpunit/PHPUnit_Selenium
sudo pear install phpunit/PHPUnit_Story

And after that, restart your server or PC if you want, PHPUnit will work.
Au final, merci encore une fois mon collègue Thierry, il a partagé un script qui permet d’automatisé d’installer le poste de travail.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s