当我用phpunit测试时,我正在为Yii2编写测试代码。然后代码覆盖检查不完全覆盖属性标签方法。它只涵盖了第一行。这是我在下面给出的测试模型代码。
public function testattributeLabels()
{
$attribute = Academicrecords::attributeLabels();
print_r($attribute);
$this->assertInternalType('array',$attribute);
$this->assertContains('Student Name',$attribute);
$this->assertEquals('Student Name',$attribute['student_id']);
$this->assertEquals('ID',$attribute['id']);
$this->assertEquals('School Name',$attribute['school_name']);
$this->assertEquals('Class',$attribute['class']);
$this->assertEquals('Stream',$attribute['stream']);
$this->assertEquals('Created On',$attribute['created_on']);
$this->assertEquals('Modified On',$attribute['modified_on']);
$this->assertEquals('Created By',$attribute['created_by']);
$this->assertEquals('Modified By',$attribute['modified_by']);
}
这是我的模型代码
public function attributeLabels()
{
return [
'id' => 'ID',
'student_id' => 'Student Name',
'school_name' => 'School Name',
'class' => 'Class',
'stream' => 'Stream',
'created_by' => 'Created By',
'created_on' => 'Created On',
'modified_by' => 'Modified By',
'modified_on' => 'Modified On',
];
}
这是我的代码结果 This is my Codeception result code
答案 0 :(得分:0)
由于attributeLabels()不是静态函数,您可能想尝试这个。不确定它是否能解决你的问题。
css: [
'~assets/css/main.css',
'~assets/css/admin.css',
],