在 yii 中使用 phpunit - 父类未被识别
我为在 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);
}
}
?>
I wrote a little test case for a model I created in Yii and when I try to run the test, it gives me: Fatal error: Class
'.....\ActiveRecord' not found in Commissions.php'
Now, my class (commissions.php) inherits the ActiveRecord class in Yii but how can I tell PHPunit where to find it? I've tried using an include statement in Commissions.php but then it can't find the class that ActiveRecord inherits and so on.
<?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);
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的测试用例开头应该包含以下内容:
What you should have at the beginning of your testcase is: