时,我有这部分代码在我indexController的:错误运行单元测试
public function init()
{
$this->_translate = $this->getInvokeArg('bootstrap')->getResource('translate');
}
这工作都很好,在珠三角我没有得到任何错误
但是,当我运行我的单位测试中,它会生成以下错误:
Fatal error: Call to a member function getResource() on a non-object in K:\stage 5\application\controllers\IndexController.php on line 9
这是我testcode:
class IndexControllerTest extends ControllerTestCase
{
public function testCanDisplayOurHomepage()
{
//Go to the main page of the webapplication
$this->dispatch('/');
//check if we don't end up in an error controller
$this->assertNotController('error');
$this->assertNotAction('error');
//Ok no error lets check if we are on the home page
$this->assertModule('default');
$this->assertController('index');
$this->assertAction('index');
$this->assertResponseCode(200);
}
}
请让我知道类的getResource和类$ this-> getInvokeArg('bootstrap')。 – Gaurav 2011-01-23 17:50:36