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

Already on GitHub? Sign in to your account

Yii 1.1.12 CTestCase doesn't work with PHPUnit 3.7.7 #1563

Closed
DexterHD opened this Issue Oct 13, 2012 · 11 comments

Comments

10 participants

I have PHPUnit 3.7.7, Yii framework 1.1.12 and PHP 5.4.5. My include_path variable is:

.:/usr/local/php/lib/php:/usr/local/php/lib/php/yii/framework:/usr/local/php/lib/php/PHPUnit:/usr/local/php/lib/php/PEAR

But when I'm trying to start some unit test for my Yii Framework application I get this error:

Fatal error: Uncaught exception 'LogicException' with message 'Function 'phpunit_autoload' not found (function 'phpunit_autoload' not found or invalid function name)' in /usr/local/php/lib/php/yii/framework/YiiBase.php on line 628

LogicException: Function 'phpunit_autoload' not found (function 'phpunit_autoload' not found or invalid function name) in /usr/local/php/lib/php/yii/framework/YiiBase.php on line 628

@ghost ghost assigned samdark Oct 13, 2012

I have the same problem.

Use:

require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Autoload.php');

instead of:

require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
spl_autoload_unregister('phpunit_autoload');
Yii::registerAutoloader('phpunit_autoload');
Contributor

tanakahisateru commented Oct 25, 2012

I also have.

I can use PHPUnit 3.7 with modifying yii/framework/test/CTestCase.php to:

require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');
if (in_array('phpunit_autoload', spl_autoload_functions())) { // PHPUnit >= 3.7 'phpunit_alutoload' was obsoleted
    spl_autoload_unregister('phpunit_autoload');
    Yii::registerAutoloader('phpunit_autoload');
}
Contributor

francistm commented Oct 25, 2012

Thanks @tanakahisateru ;-)

Contributor

DaSourcerer commented Oct 29, 2012

Can we get @tanakahisateru's code in? I suspect this is also the culprit of the failing travis builds for php 5.3+ ...

Contributor

tanakahisateru commented Oct 29, 2012

I will send a pull request soon.

@samdark samdark closed this in 5357ebe Oct 29, 2012

Owner

samdark commented Oct 29, 2012

@tanakahisateru applied your proposed solution. Works like a charm. Thanks for it.

Contributor

tanakahisateru commented Oct 29, 2012

@samdark Thanks for your commit.

works like a charm 👍 thanks !

Brilliant, thanks @tanakahisateru

Excellent.... Excellent...... , thank you very much....@tanakahisateru.... my code look like this in yi-1.1.12//framework/test/CTestCase.php,

= 3.7 'phpunit_alutoload' was obsoleted spl_autoload_unregister('phpunit_autoload'); Yii::registerAutoloader('phpunit_autoload'); } /** - CTestCase is the base class for all test case classes. * - @author Qiang Xue qiang.xue@gmail.com - @Version $Id$ - @Package system.test - @SInCE 1.1 */ abstract class CTestCase extends PHPUnit_Framework_TestCase { }

Thanks. Helped me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment