0
我尝试做功能测试,比如进入Yii权威指南。Yii功能测试
这是我的灯具到tbl_showcase.php:
return array(
'sample1'=>array(
'title'=>'Welcome',
'content'=>'A main page test',
'row_type'=>1,
),
'sample2'=>array(
'title'=>'About',
'content'=>'An about page test',
'row_type'=>2,
),
);
这是我的测试类:
class ShowcaseTest extends WebTestCase
{
public $fixtures = array('showcase'=>'Showcase');
public function testIndex()
{
$this->open('/');
$this->assertTextPresent($this->showcase['sample1']['title']);
$this->assertTextPresent('Welcome');
$this->assertTextPresent($this->showcase['sample1']['content']);
$this->assertTextPresent('A main page test');
}
}
我开始测试
phpunit functional/ShowcaseTest.php
,并得到一个错误:
Time: 8 seconds, Memory: 6.25Mb
There was 1 error:
1) ShowcaseTest::testIndex
Exception: Unknown property 'name' for class 'ShowcaseTest'.
/home/myfolder/web/yii/framework/test/CWebTestCase.php:48
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
我是Yii的初学者。请稍微了解一下“明确给Namecase属性添加ShowcaseTest类”。请显示代码示例,如果可能的话。我可以对俄罗斯和乌克兰说话。 – starter 2012-02-25 13:00:45
我不明白什么是“名称”属性。这是谁的名字? – starter 2012-02-25 13:07:38
测试基础设施取决于测试类的名称属性,但您定义的类没有它 - 除非您手动分配属性。看起来,这个属性的价值实际上并不相关。 – raina77ow 2012-02-25 13:12:21