2012-04-12 87 views
0

如何在我的测试用例中回应控制器操作的html/xml输出?Zend_Test_PHPUnit如何打印异常/输出?

这里是我的测试用例:

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?

回答

0

上帝我今天慢:

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

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

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

    $this->assertNotRedirect(); 
}