PHPUnit failed to open the required file

I looked through similar problems on SO, but to no avail. I am running PHP 5.3.6 and phpunit version 3.6.10. When trying to run a simple test:

require_once 'PHPUnit/Framework.php'; class UserTest extends PHPUnit_Framework_TestCase { } 

I get 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 that the installation location was duplicated, but it seems that when you run which phpunit path is as follows: /usr/bin/phpunit . However, it is also installed in /Users/user/pear/bin/phpunit . I tried updating all channels and reinstalling PEAR and PHPUnit, but the problem still exists. I work on OSX Lion. Any help would be greatly appreciated.

+6
source share
2 answers

Just delete the line

 require_once 'PHPUnit/Framework.php'; 

and everything should work.

You do not need to include/require anything related to PHPUnit with (at least) PHPUnit 3.6 , and you cannot include this file because it no longer exists in the distribution.

Moving phpunit will take care of loading everything PHPUnit requires :)

+15
source

As others have indicated, Framework.php is no longer required.

But in any case, if you already have too many test files written and having an include statement, then fixing them will be a cumbersome task. In this case, I had to face.

If you need a quick workaround, create an empty Framework.php file. This will solve the problem. Create an empty file called Framework.php in your PHPUnit directory. (for example: at: /usr/share/php/PHPUnit/Framework.php).

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

+1
source

Source: https://habr.com/ru/post/910302/


All Articles