我为在Yii中创建的模型编写了一个小测试用例,当我尝试运行测试时,它给了我:致命错误:类
'.....\ActiveRecord' not found in Commissions.php'
现在,我的类(commissions.php)继承了Yii中的ActiveRecord类,但是如何告诉PHPunit在哪里找到它呢?我已经尝试在Commissions.php中使用include语句,但是它找不到ActiveRecord继承的类,依此类推。
<?php
include_once('Commissions.php');
class CommissionsTest extends PHPUnit_Framework_TestCase
{
// Here, the idea would be to check one or two employees manually or based on the SQL query
// Or even a previous value using the function so that when any changes are made, the value
// remains the same while using the same arguments.
public function setUp()
{
$this->employee = new Commissions();
$this->employee->employeeId = 'V1S';
$this->employee->year = 2012;
$this->employee->period = 1;
}
public function testAttributes()
{
$this->assertEquals('V1S', $this->employee->employeeId);
$this->assertEquals(2012, $this->employee->year);
$this->assertEquals(1, $this->employee->period);
}
}
?>
答案 0 :(得分:0)
在测试用例的开头你应该拥有的是:
Yii:import('application.models.Commissions'); //or whatever your model is called
class CommissionsTest extends CDbTestCase { //Not PHPUnit_Framework_TestCase