我从动作控制器,它使用应用程序以及访问选项,但我已经打了一个问题,当我试图单元测试吧:
PHP Fatal error: Call to a member function getOptions() on a non-object in /home/zendtest/library/ZC/Action/Helper/Signup.php on line 43
对于我的测试中,我跟着从ZC设置在http://www.zendcasts.com/unit-testing-action-helpers/2010/11/
与源代码可以在这里
我在测试/库/ ZC /动作/助手/ SignupTest.php增加了另一个测试:
public function testMyTest()
{
$helper = new ZC_Action_Helper_Signup();
$this->dispatch('/');
$controller = new IndexController($this->getRequest(),
$this->getResponse(), array());
$helper->setActionController($controller);
$this->assertType('Zend_View',$helper->getConfig());
}
我增加了以下功能/library/ZC/Action/Helper/Signup.php:
protected $_config;
public function getConfig()
{
if (null == $this->_config) {
$action = $this->getActionController();
$bootstrap = $action->getInvokeArg('bootstrap');
$config = $bootstrap->getOptions();
$this->_config = new Zend_Config($config);
}
return $this->_config;
}
我怎样才能正确地测试这个动作的辅助功能?