2
votes

I have been attempting to run PHPUnit unit tests on a preexisting project built on the Yii framework. Using the terminal in Ubuntu 15.04, I globally installed PHPUnit through Composer, and added "~/.composer/vendor/bin" to my path. The problem is, the tests fail to run. They return a warning and an error:

The Warning:

PHP Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in [Yii Project root]/framework/test/CTestCase.php on line 11

The Error:

PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php'

I know that the Version.php exists in

~/.composer/vendor/phpunit/phpunit/src/Runner

But it seems the PHP looks for it in the wrong place. Why can't Version.php be found by the require statement, and where should I install it so that it could?

1

1 Answers

2
votes

I suppose you already have PHPUnit installed in an older version via PEAR. This might conflict with PHPUnit via Composer.

How do you start PHPUnit? Run which phpunit to find out if your system things it find it where you wouldn't think it is.

The best idea is to remove all globally installed instances of PHPUnit and only use versions provided by Composer (the other solution would be to never use PHPUnit inside a project, and only install a recent version globally).