Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error 'File/Iterator/Autoload.php' not found when running phpunit

I am getting this error while i tried to run testclass in phpunit.

C:\xampp\htdocs\unittest>phpunit UnitTest usertest.php PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream No such file or directory in C:\xampp\php\pear\PHPUnit\Autoload.php on line 45 PHP Stack trace: PHP   1. {main}() C:\xampp\php\phpunit:0 PHP   2. require() C:\xampp\php\phpunit:41  Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in C:\xampp\php\pear\PHPUnit\Autoload.php on line 45  Call Stack:     0.0004     325352   1. {main}() C:\xampp\php\phpunit:0     0.0026     366520   2. require('C:\xampp\php\pear\PHPUnit\Autoload.php')xampp\php\phpunit:41  PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.;C:\php\pear') in C:\xampp\php\pear\PHPUnit\Autoload.php on line 45 PHP Stack trace: PHP   1. {main}() C:\xampp\php\phpunit:0' 

could anyone give solution to this ??

Note: i am using windows 7.

Thanks,

like image 556
pearlsoft Avatar asked Jan 02 '12 12:01

pearlsoft


2 Answers

A possible reason that this might happen is that your php include_path is not set correctly. Please make sure you have the appropriate path to PEAR available. For my WAMP installation it would be:

include_path=".;C:\wamp\bin\php\php5.3.8\PEAR\PEAR" 

However, it will most likely be different on your system.

A side note, you will want to update both your apache php.ini, as well as your php.ini located in your PHP installation folder. CLI the default php.ini, and web requests (and often times other software that you might be using PEAR packages for) will use the apache php.ini.

Hope this helps.

like image 125
Syntaqx Avatar answered Oct 11 '22 13:10

Syntaqx


Your phpunit installation is broken. The easiest fix for this is

pear install --force --alldeps phpunit/phpunit 

and see if what worked out.

You will need the most current pear version 1.9.4. If you don't have that version install it using the go-pear.phar. If you are running from xammp for something don't try to fix the pear installation they ship. Usually it's a LOT easier to reinstall it.

If you want to you can try to just install the missing package too:

pear install phpunit/File_Iterator 

(add a --force if pear tells you that it is already installed)

like image 30
edorian Avatar answered Oct 11 '22 13:10

edorian