Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit can't run #1173

Closed
songdragon opened this issue Mar 10, 2014 · 3 comments
Closed

PHPUnit can't run #1173

songdragon opened this issue Mar 10, 2014 · 3 comments

Comments

@songdragon
Copy link

PHPUnit is installed by pear install pear.phpunit.de/PHPUnit.
The version is:
$ phpunit --version
PHPUnit 4.0.4 by Sebastian Bergmann.

When a php test is running, it promps as follows:

phpunit unit/MessageTest.php
PHP Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /home/songdragon/Softwares/Dev/apache/apache2/htdocs/yii/framework/test/CTestCase.php on line 11

Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /home/songdragon/Softwares/Dev/apache/apache2/htdocs/yii/framework/test/CTestCase.php on line 11
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/home/songdragon/Softwares/Dev/apache/apache2/htdocs/demo/protected/components:/home/songdragon/Softwares/Dev/apache/apache2/htdocs/demo/protected/models:/home/songdragon/Softwares/Dev/PHP/php/lib/php') in /home/songdragon/Softwares/Dev/apache/apache2/htdocs/yii/framework/test/CTestCase.php on line 11

Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/home/songdragon/Softwares/Dev/apache/apache2/htdocs/demo/protected/components:/home/songdragon/Softwares/Dev/apache/apache2/htdocs/demo/protected/models:/home/songdragon/Softwares/Dev/PHP/php/lib/php') in /home/songdragon/Softwares/Dev/apache/apache2/htdocs/yii/framework/test/CTestCase.php on line 11

@whatthejeff
Copy link
Contributor

Looks like the same issue as #1167.

As of 4.0, PEAR is simply a distribution channel for our phar. Requiring individual files from PHPUnit will no longer work.

And really, since PHPUnit has had an autoloader for quite a while now, there's really no reason for Yii or any other framework to be including these files.

@songdragon
Copy link
Author

Thanks! I have downloaded source code of phpunit, and copy some directories and the autoload.php file into lib/php/PHPUnits and rename the file to Autoload.php.
Then phpunit works when running tests.

@whatthejeff
Copy link
Contributor

No problem :)

Konafets added a commit to Konafets/PHP_CodeSniffer that referenced this issue Apr 14, 2014
Since version 4.0.x PHPUnit will be distributed as a PHAR file via PEAR[1]. This means all the dependencies in form of several files are bundled into one single file. This break any require statements. As you can see at [2], PHPUnit comes with an autoloader which makes any require statement obsolete anyway. 

This change fixes the error "Warning: require_once(PHPUnit/Framework/TestSuite.php): failed to open stream: No such file or directory in /Volumes/HDD/Users/sok/Development/PHP/PHP_CodeSniffer/tests/TestSuite.php on line 17"

[1] https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-4.0.0#obtaining-phpunit-40
[2] sebastianbergmann/phpunit#1173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants