Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit failed opening required file

Tags:

php

phpunit

I've browsed through similar problems on SO, but to no avail. I'm running PHP 5.3.6 and phpunit version 3.6.10. When attempting to execute a simple test:

require_once 'PHPUnit/Framework.php';

class UserTest extends PHPUnit_Framework_TestCase {
}

I receive the following error:

PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Framework.php'
(include_path='.:/Users/username/pear/share/pear:/usr/lib/php/pear/:/Users/username/pear/share/pear/PHPUnit') in ...

When reinstalling PHPUnit, I'm not sure if the install location was duplicated, but it appears that when running which phpunit, the path is: /usr/bin/phpunit. However, it appears to also be installed in /Users/user/pear/bin/phpunit. I've tried updating all channels and reinstalling PEAR and PHPUnit, but the problem still exists. I'm running on OSX Lion. Any help would be greatly appreciated.

like image 454
naivedeveloper Avatar asked Mar 09 '12 01:03

naivedeveloper


2 Answers

Just remove the line

require_once 'PHPUnit/Framework.php';

and everything should work.

You don't need to include/require anything PHPUnit related since (at least) PHPUnit 3.6 any more and you can't include that file because it doesn't exist any more in the distribution.

The phpunit runner will take care of bootstrapping everything that is needed by PHPUnit :)

like image 153
edorian Avatar answered Nov 09 '22 18:11

edorian


As others pointed out, Framework.php is not required anymore.

But in any case if you already have too many test files written and having the include statement, then fixing them going to be a cumbersome task. Which was the case I had to face.

If a quick workaround is needed, create an empty Framework.php file. That will resolve the problem. Create an empty file named Framework.php under your PHPUnit directory. (eg: at: /usr/share/php/PHPUnit/Framework.php).

sudo touch /usr/share/php/PHPUnit/Framework.php

like image 39
nilufer Avatar answered Nov 09 '22 19:11

nilufer