Yii PHPUnit Testing PHP Fatal error: Class ‘CActiveRecord’ not found..Netbeans

When you create PHPUnit tests for your models in Yii using netbeans you may encounter this problem

PHP Fatal error:  Class 'CActiveRecord' not found..

The easiest solution is to include the following at the top of the model class, for example if the class is User then your code should look like


$yii='/opt/lampp/htdocs/yii/framework/yii.php';
require_once($yii);

class User extends CActiveRecord
{
// ......

}

Cheers 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *