【问题标题】:Failed asserting last controller used <"error"> was "index"断言使用的最后一个控制器失败 <"error"> 是 "index"
【发布时间】:2015-03-03 23:36:07
【问题描述】:

我正在尝试使用 PHPUnit 在 Zend Framework 1 上运行测试。我可以运行测试,但它给了我错误:

$ ./library/bin/phpunit tests/application/controllers/IndexControllerTest.php
PHPUnit 3.7.27 by Sebastian Bergmann.

Configuration read from /var/www/vhosts/qasystem/qasystem/phpunit.xml

F

Time: 3.38 seconds, Memory: 15.75Mb

There was 1 failure:

1) IndexControllerTest::testIndexAction
Failed asserting last controller used <"error"> was "index"

/var/www/vhosts/qasystem/qasystem/library/zendframework/zendframework1/library/Zend/Test/PHPUnit/ControllerTestCase.php:1000
/var/www/vhosts/qasystem/qasystem/tests/application/controllers/IndexControllerTest.php:18

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

如果它抛出错误,我如何查看错误是什么?我已将 application.ini 设置为

phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

...对于那个环境。如果这是一个浏览器,我将能够看到屏幕上的错误/异常。无论如何在 CLI 中查看 PHPUnit 中的错误是什么?谢谢

【问题讨论】:

    标签: php zend-framework phpunit


    【解决方案1】:

    Zend Framework 捕获任何错误并在输出中显示错误消息。所以对于这个问题,在你的调度命令之后,var_dump($this-&gt;getResponse()-&gt;outputBody()

    然后,当您重新运行测试时,将输出 Zend Framework 正在检查的 html 输出,您可以看到错误。这将是一个很大的墙-o-text,但您将能够看到错误是什么。

    【讨论】:

      猜你喜欢
      • 2011-04-05
      • 2011-08-27
      • 1970-01-01
      • 1970-01-01
      • 2014-07-08
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多