YII - unit testing not working

When I run the PHP unit test with the YII framework, I got the following error:

PHP Fatal error: Uncaught exception 'LogicException' with message 'Function 'phpunit_autoload' not found (function 'phpunit_autoload' not found or invalid function name)' in /var/www/yii/framework/YiiBase.php:628 

Does anyone know how to solve this problem?

+4
source share
2 answers

Its a problem with YII CTestCase.php (yii / framework / test / CTestCase.php). Got a solution, now it works like a charm. Here he is:

Using:

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

instead:

 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'); 
+1
source

This bug was fixed in Yii 1.1.13

See this Github question: https://github.com/yiisoft/yii/issues/1563

and here is the line in CHANGELOG: https://github.com/yiisoft/yii/blob/1.1.13/CHANGELOG#L119

0
source

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


All Articles