Phpunit Fatal Error

I’m trying “create PHPUnit tests” with netbeans, but i’m having the following error:

"PHP Fatal error: Class ‘CActiveRecord’ not found in “.../protected/models/Book.php”.

Someone know how i can fix this?

I think you haven’t defined to load all the available models. Can you check your config/test.php against the below code block ?

   'import' => array(



Sounds like the yii autoloader is broken there. Could you give us a rough overview about your setup?

My configuration file was generated by the command yiic webapp, these have the same settings. I have not changed anything in particular.

Just add below in Book.php file.



  • @property Type $type

  • @property Grade $grade

  • @property Person[] $people

  • @property Publisher[] $publishers

  • @property Tag[] $tags


[color="#FF0000"]require_once(’/var/yii/1.1.13/framework/yii.php’);[/color] <== your yii framework path + yii.php

class Book extends CActiveRecord



 * Returns the static model of the specified AR class.

 * @param string &#036;className active record class name.

 * @return Book the static model class


public static function model(&#036;className=__CLASS__)


	return parent::model(&#036;className);





Thanks for this suggestion, which resolved the issue. Is this a bug? You shouldn’t have to manually require the Yii bootstrap file in every model in order to enable creating PHPUnit tests with Skeleton Generator.

¿Have you get a different solution for this?

i have the same situation