【发布时间】:2014-06-11 01:40:39
【问题描述】:
问题:运行 phpunit 导致下一个错误:
PHPUnit_Framework_Exception: PHP Fatal error: Using $this when not in object context in /path/to/index.phtml
回溯:
#0 include() called at [/path/to/Zend/View.php:108]
#1 Zend_View->_run(/path/to/index.phtml) called at [/path/to/Zend/View/Abstract.php:880]
#2 Zend_View_Abstract->render(index/index.phtml) called at [/path/to/Zend/Controller/Action/Helper/ViewRenderer.php:897]
#3 Zend_Controller_Action_Helper_ViewRenderer->renderScript(index/index.phtml, ) called at [/path/to/Zend/Controller/Action/Helper/ViewRenderer.php:918]
#4 Zend_Controller_Action_Helper_ViewRenderer->render() called at [/path/to/Zend/Controller/Action/Helper/ViewRenderer.php:957]
#5 Zend_Controller_Action_Helper_ViewRenderer->postDispatch() called at [/path/to/Zend/Controller/Action/HelperBroker.php:277]
#6 Zend_Controller_Action_HelperBroker->notifyPostDispatch() called at [/path/to/Zend/Controller/Action.php:523]
#7 Zend_Controller_Action->dispatch(indexAction) called at [/path/to/Zend/Controller/Dispatcher/Standard.php:295]
无法理解我缺少什么,但正如我所见,include 是从 Zend_View->run 调用的,因此 $this 必须在视图中可见(并且它在没有 phpunit 的情况下也可以工作)。
你能告诉我挖掘的方向或这种行为的一些原因吗?
【问题讨论】:
标签: php zend-framework view phpunit