我有这个发出 Ajax 请求的测试代码,我需要测试响应是有效的 JSON,但是我无法得到响应。我正在使用 PHPUnit 3.5.15 和 ZendFramework 1.11.11
class ClienteControllerTest extends ControllerTestCase
{
public function testIndexAjaxAction()
{
$this->login();
$this->resetRequest()->resetResponse();
$this->dispatch("/cliente/ajax/?sEcho=2&iColumns=7....");
$this->assertNotController('error');
$this->assertNotAction('error');
$this->assertController('cliente');
$this->assertAction('ajax');
$this->assertNotRedirect();
$this->assertResponseCode(200, 'Ajax index fallita');
//$this->assertNotNull(json_decode($this->getResponse()->getBody()));
//$this->getResponse()->outputBody();
}
我试图设置 die(print_r($this->getResponse)) 我得到
Zend_Controller_Response_HttpTestCase Ob
(
[_body:protected] => Array
(
)
[_exceptions:protected] => Array
(
)
[_headers:protected] => Array
(
)
[_headersRaw:protected] => Array
(
)
[_httpResponseCode:protected] => 200
[_isRedirect:protected] =>
[_renderExceptions:protected] =>
[headersSentThrowsException] => 1
)
1
我怎样才能在 dispatch() 之后得到响应?