php – Zend_Controller_Response_Exception:无法发送标头;

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – Zend_Controller_Response_Exception:无法发送标头;脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
当运行zend应用程序的所有测试时,这一行:

PRotected function _getResp()
{
    if (is_null($this->_response))
        $this->_response = new Zend_Controller_Response_Http();
    return $this->_response;
}
.......
$this->_getResp()->setHeader('Content-tyPE','text/htML; charset=utf-8',true);

生成以下错误

结果 – 测试失败了

解决方法

这是因为PHPUnIT在测试运行之前生成输出.您需要在测试用例中注入Zend_Controller_Response_HttptestCase. Zend_Controller_Response_Http的这个子类实际上并不发送头文件输出任何内容,并且它不会抛出异常,因为它不关心输出是否已经发送过.

只需将以下方法添加到上面的类中.

public function setResp(Zend_Controller_Response_Http $resp) {
    $this->_response = $resp;
}

创建一个新的Zend_Controller_Response_HttpTestCase并将其传递给您正在测试的对象上的setResp().这也将允许您验证正确的@L_512_13@是否与输出一起“发送”.

脚本宝典总结

以上是脚本宝典为你收集整理的php – Zend_Controller_Response_Exception:无法发送标头;全部内容,希望文章能够帮你解决php – Zend_Controller_Response_Exception:无法发送标头;所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。