【问题标题】:PHPUnit stoping with no feedback when trying to dispatch in Zend Framework controllers尝试在 Zend Framework 控制器中调度时 PHPUnit 停止且没有反馈
【发布时间】:2013-04-10 16:05:18
【问题描述】:

[编辑] 我的测试环境如 http://www.slideshare.net/DragonBe/unit-testing-after-zf-18 所示,并使用来自 https://github.com/DragonBe/zfunittest 的源代码。

当我尝试运行 simples dispatch("/") 时,我得到以下答案:

C:\wamp\www\MyProject\tests>phpunit
PHPUnit 3.7.19 by Sebastian Bergmann.

Configuration read from C:\wamp\www\MyProject\tests\phpunit.xml

.
C:\wamp\www\MyProject\tests>

有人知道发生了什么吗?

phpunit 只是停止,没有给我任何反馈。

我在 Windows 7x 64、ZF 1.11、PHP 5.4.3 和 PHPunit 3.7 上运行 Wampserver 2.2。

提前谢谢大家。

【问题讨论】:

  • 到目前为止你尝试过什么?如果在 dispatch() 方法调用之后执行 var_dump(),你在终端中看到什么了吗?
  • 你拼错了display_erros,你确定你看到错误了吗?
  • display_errors 已正确写入我的本地副本。还没有任何工作。实际上,只有当我尝试制作抽签时才会出现问题。如果我之前 var_dump() 会显示错误,但是当我执行 $this->dispatch("/") 时,例如,没有其他任何事情发生。 phpunit 只打印一个“。”它完成了。

标签: unit-testing zend-framework phpunit


【解决方案1】:

为了解决这个问题,我尝试重写我的文件。

从我的 TestHelper.php 的开头删除 ob_start(),给了我一个接一个的错误(感谢上帝!),因为我解决了每个错误(并且 phpunit 不再停止执行):

  • 必须在任何输出发送到 浏览器
  • 没有为此应用程序定义默认模块
  • 致命错误:在非对象上调用成员函数 hasResource() 在 ...ErrorController.php 中

在其他帖子中进行了一些搜索后,我在我的 IndexControllerTest.php 的 setUp 方法中尝试了以下操作:

public function setUp(){

    $this->bootstrap('session');
    $front = Zend_Controller_Front::getInstance();
    $front->setParam('noErrorHandler', true);
    $this->getFrontController()->setControllerDirectory(APPLICATION_PATH . '/controllers');
    parent::setUp();
}

那么,现在一切正常了。

感谢所有帮助过我的人。

【讨论】:

    猜你喜欢
    • 2014-09-25
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 2012-04-18
    • 2020-09-09
    相关资源
    最近更新 更多