0

I just stuck all this morning to figure out this, but without luck.

I create a test under tests/unit

<?php

  class DbTest extends CTestCase {

    public function testConnection() {
  $this->assertTrue( true );
    }
  }

?>

when I run it in the terminal

$ cd tests
$ phpunit unit/DbTest.php

I get this error:

PHPUnit 3.7.8 by Sebastian Bergmann.

Function 'phpunit_autoload' not found (function 'phpunit_autoload' not found or invalid function name)

my phpunit version is 3.7.8

2 Answers 2

2

This is a known bug.

You need to alter the autoloader's

or

downgrade PHPUnit to 3.7.1

Sign up to request clarification or add additional context in comments.

Comments

2

Following thing worked well for me. Found googling. http://www.yiiframework.com/forum/index.php/topic/37294-yii-unit-test-not-working/

Old Code in framework/test/CTestCase.php, Comment it out.

   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');

And change to this

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');

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.