0

如何在我的测试用例中回显来自控制器操作的 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 呢?

4

1 回答 1

0

上帝我今天很慢:

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

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

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

    $this->assertNotRedirect();
}
于 2012-04-12T15:51:50.590 回答