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

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

Projects
None yet
10 participants
@DexterHD
Copy link

DexterHD commented Oct 13, 2012

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

@jmalinens

This comment has been minimized.

Copy link

jmalinens commented Oct 20, 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');
@tanakahisateru

This comment has been minimized.

Copy link
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');
}
@francistm

This comment has been minimized.

Copy link
Contributor

francistm commented Oct 25, 2012

Thanks @tanakahisateru ;-)

@DaSourcerer

This comment has been minimized.

Copy link
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+ ...

@tanakahisateru

This comment has been minimized.

Copy link
Contributor

tanakahisateru commented Oct 29, 2012

I will send a pull request soon.

@samdark

This comment has been minimized.

Copy link
Member

samdark commented Oct 29, 2012

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

@tanakahisateru

This comment has been minimized.

Copy link
Contributor

tanakahisateru commented Oct 29, 2012

@samdark Thanks for your commit.

@peterver

This comment has been minimized.

Copy link

peterver commented Oct 31, 2012

works like a charm 👍 thanks !

@mplanigale

This comment has been minimized.

Copy link

mplanigale commented Nov 8, 2012

Brilliant, thanks @tanakahisateru

@gaurishpatil

This comment has been minimized.

Copy link

gaurishpatil commented Nov 26, 2012

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 { }
@CityBeekeeper

This comment has been minimized.

Copy link

CityBeekeeper commented Jan 23, 2014

Thanks. Helped me too.

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