如何解决PHPUNIT如何为这种情况制作UT?
我正在尝试使用PHPUNIT来实现以下功能:
/**
* Get the _getValueHelperhelps to return a magic value from the matrix
* @return string
*/
protected function _getValueHelper()
{
return Zend_Controller_Action_HelperBroker::getStaticHelper('valueHelper');
}
这是要测试的函数,它调用上面的帮助器:
protected function _protectedFunctionMagic( $view ) {
if($this->_shopName->values->showLog){
$view->showLog = array(
"value1" => Zend_Registry::get('conversationId'),"value2" => $this->_getValueHelper()->getValue()
);
}
}
我已经尝试了几件事,阅读了文档,但是无法掌握它,我该如何模拟这行
"value2" => $this->_getValueHelper()->getValue()
我尝试了很多事情,但似乎没有任何效果,甚至无法进入断言阶段……当调用仅是一个函数时,我确实工作了
"value2" => $this->_getValueHelper()
但是现在代码已更新,如何模拟这种特殊情况?
$testMock->expects($this->any())
->method('_getValueHelper')
->with('getValue')
->will($this->returnValue('1234'));
结果:
Expectation failed for method name is equal to <string:_getValueHelper> when invoked zero or more times
Parameter count for invocation PEP_Controller_Plugin_ConfigurableStore::_getValueHelper() is too low
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。