1
votes

I'm trying to get an installation of phpunit going on my os x Lion with MAMP. I have installed phpunit at /Applications/MAMP/bin/php/php5.4.4/lib/php.

When I run phpunit in the terminal I get this error:

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

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

I noticed that the include path is "." so I ran this in the terminal to find which php.ini file is being loaded "php --ini" and get this

Loaded Configuration File:         /Applications/MAMP/bin/php/php5.4.4/conf/php.ini

The include path in the php.ini file is

include_path = ".:/Applications/MAMP/bin/php/php5.4.4/lib/php:/usr/lib/php/pear:/usr/bin/phpunit"

So why does it come out as "." when running phpunit in the terminal?

As a check, I created a php file with this code:

echo get_include_path();

when I run that file in the terminal it outputs the include path in the php.ini file.

I also added echo get_include_path(); to the top of /Applications/MAMP/bin/php/php5.4.4/lib/php/PHPUnit/Autoload.php. When I run phpunit in the terminal with this, the outputed include path is ".:"

It seems like phpunit is loading a different include path which needs to be fixed.

2

2 Answers

0
votes

It could be that you have 2 PHPUnit installs, one in /usr/lib/php/pear/ and one in your MAMP dir. You get the first one executed.

If that's the case, then you should change your $PATH to have the MAMP php bin dir at first position.

0
votes

The easy way for me was to simply download the latest version directly from: https://phar.phpunit.de/phpunit.phar, then locate where the file was downloaded in Terminal and:

machine:~ username$ chmod +x phpunit.phar

machine:~ username$ mv phpunit.phar /usr/local/bin/phpunit

Adjust your PATH, for instance in .profile:

machine:~ username$ pico .profile

Ensure that you have this line, if not, just include:

export PATH=/usr/local/bin/:$PATH

Quit and re-open Terminal or:

machine:~ username$ source .profile

and now

machine:~ username$ phpunit --version

should show the latest installed version