断言最后使用的控制器失败<“error”>是“索引”

时间:2015-01-06 10:09:23

标签: php zend-framework phpunit

我试图用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中的错误是什么?感谢

1 个答案:

答案 0 :(得分:0)

Zend Framework捕获任何错误并在输出中显示错误消息。因此,针对此问题,在您的调度命令var_dump($this->getResponse()->outputBody()之后。

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