Zend_Test_PHPUnit如何打印异常/输出?

时间:2012-04-12 15:48:42

标签: zend-framework phpunit

如何在测试用例中回显控制器操作的html / xml输出?

这是我的测试用例:

public function testCreateAccountIsASuccessfulRequest()
{
    $this->dispatch('/v2/user/create-account');

    $this->assertFalse($this->response->isException());

    $this->assertNotRedirect();
}

在命令行中打印出来:

test# /usr/local/bin/phpunit --verbose Controllers_UserControllerTest.php
PHPUnit 3.6.10 by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 12.50Mb

There was 1 failure:

1) Controllers_UserControllerTest::testCreateAccountIsASuccessfulRequest
Failed asserting that true is false.

/path/to/tests/Controllers/UserControllerTest.php:17
/usr/local/bin/phpunit:46

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

我不确定实际的异常是什么。怎么看?另外,如何查看控制器动作的实际输出?那么它发送给浏览器的HTML / XML?

1 个答案:

答案 0 :(得分:0)

上帝我今天很慢:

public function testCreateAccountIsASuccessfulRequest()
{
    $this->dispatch('/v2/user/create-account');

    echo $this->getResponse()->getBody();

    $this->assertFalse($this->response->isException());

    $this->assertNotRedirect();
}