[Solved] Unit test can't find File/Iterator/Autoload.php

This arose while I was going through the Agile book, but I don’t think it is related to the book per se, so I’m posting here (too) for more visibility.

Briefly, a unit test that succeeded yesterday now fails – i.e. not the test failing but PHP error trying to run the test. Here is the console transcript:

amd @ /Library/WebServer/Documents/demo/protected/tests: phpunit unit/MessageTest.php

Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /usr/lib/php/PHPUnit/Autoload.php on line 45

Fatal error: require_once(): Failed opening required ‘File/Iterator/Autoload.php’ (include_path=’.:’) in /usr/lib/php/PHPUnit/Autoload.php on line 45

Now… what changed? I did reboot between sessions.

The "missing" file is definitely at /usr/lib/php/File/Iterator/Autoload.php. That include path in the error message looks suspiciously scant though… whose include path is it? PHP? Yii? Bash shell?

FWIW, the environment PATH as reported by phpinfo() is "/usr/bin:/bin:/usr/sbin:/sbin".

Fix? Thanks for any tips.

Solution: edit the /etc/php.ini file and change the include_path entry from

include_path = ".:/php/includes"


include_path = ".:/php/includes:/usr/lib/php"

Now why this wasn’t needed for earlier unit tests is a mystery. I think that PHP was getting its ini values not from /etc/php.ini.default (which already existed and also omitted the path I added) but from somewhere else. And then something I did convinced PHP to start using the .ini.default file. I edited it and then copied to plain old .ini file and searching for the File/ directory now succeeded.