Phpunit Not Working With Yii Ctestcase (Phpunit_Autoload Not Found)

Hi Folks,

I am having trouble getting php unit to work with CTestCase, it works fine with PHPUnit_Framework_TestCase

Here is the test class: -


   class DbTest extends CTestCase


        public function testConnection()





Here is the error: -

phpunit unit/DbTest.php 

PHPUnit 3.7.6 by Sebastian Bergmann.

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

Anyone come across this before?

Thanks for your help

All the best,


I’m having the same problem, did you find out how to fix it?

Well I got it changing some lines in CTestCase.php:






I had thought about changing those lines, but I was worried about dabbling in things I don’t understand ;)

Will this cause any side-effects later on?



Did you add PEAR to the include path in your php.ini? I am pretty sure that this is the problem

Btw.: You should never change Yii’s core classes. Just extend them if you need to, otherwise your changes would break when you’re updating Yii.

Search for


; Paths and Directories ;


; UNIX: "/path1:/path2"

;include_path = ".:/php/includes"

and change it to


; Paths and Directories ;


; UNIX: "/path1:/path2"

include_path = ".:/php/includes:/usr/lib/php/pear"

Note: This is my path (Mac OS X), this might be different depending on your OS etc.

I had the same issue and I temporally resolved it downgrading PHPUnit to version 3.7.1.

Thanks for the help guys, sorry I haven’t had a chance to try it out this week, my day job has been very busy! Hopefully I’ll get a chance at the weekend

All the best,


It works with PhpUnit 3.7.1 for me too.

Just tried this for myself. Works fine with 3.7.1, thanks for the help guys!

All the best,


I checked in my ini file pear entry was there


but same error. I am on PHPUnit 3.7.7…has anyone solved the problem, other than downgrading back to 3.7.1


It does not work for me too with CTestCase, it works with PHPUnit_Framework_TestCase though.

Linux Debian 2.6.32-5-686

phpunit --version

PHPUnit 3.7.7 by Sebastian Bergman



php --version

PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli)



That sucks. I am not going to downgrade my package either.

Hi all. I have some problem.

I created new issue on github about this problem.

Additionally I got it changing PHPUnit "Autoload.php".

I replaced


  function ($class){...}



function phpunit_autoload($class)

{ ... }


I know, this is not so good idea to change PHPUnit files but it will works temporary as long as this bug still opened.

It worked for me after changing the autoload php file on 3.7.7 as well. Thanks for the updates.

Has someone posted this as issue?

my solution is



 * This file contains the CTestCase class.


 * @author Qiang Xue <>

 * @link

 * @copyright Copyright &copy; 2008-2011 Yii Software LLC

 * @license


require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11


if (version_compare('3.7.7', PHPUnit_Runner_Version::VERSION) >= 0)






 * CTestCase is the base class for all test case classes.


 * @author Qiang Xue <>

 * @package system.test

 * @since 1.1


abstract class CTestCase extends PHPUnit_Framework_TestCase



This dont work for me. what can i do?

Wow, there is no solution for it. i have stuck :(

Ubuntu 12.04 - Yii 1.1.11 - PHP PHP 5.3.10 - PHPUnit 3.7.7

please help!

Is there really a massive amount of change between 3.7.1 and 3.7.7?

When i had installed it, the version was 3.7.7. how can install or downgrade to 3.7.1?

I had to uninstall/reinstall selenium and dbunit too, but it was easier than I thought

phpunit --version

PHPUnit 3.7.1 by Sebastian Bergmann.

phpunit protected/tests/unit/DbTest.php 

PHP Fatal error:  Class 'CTestCase' not found in /var/www/trackstar/protected/tests/unit/DbTest.php on line 3

The problem is still there !

I tired from install/remove packages and search in google. is anyone how to i can completely remove PEAR Packages? I am going to a fresh install from scratch.


This is latest error:

phpunit unit/DbTest.php 

PHP Warning:  require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to open stream: No such file or directory in /var/www/yii/framework/test/CWebTestCase.php on line 12

PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Extensions/SeleniumTestCase.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/yii/framework/test/CWebTestCase.php on line 12