Zend framework 使用PHPUnit can';t getResponse
我有这个测试代码,它发出一个Ajax请求,我需要测试响应是否是有效的JSON,但是我无法得到响应。我正在使用phpunit3.5.15和zendframework1.11.11Zend framework 使用PHPUnit can';t getResponse,zend-framework,phpunit,Zend Framework,Phpunit,我有这个测试代码,它发出一个Ajax请求,我需要测试响应是否是有效的JSON,但是我无法得到响应。我正在使用phpunit3.5.15和zendframework1.11.11 class ClienteControllerTest extends ControllerTestCase { public function testIndexAjaxAction() { $this->login(); $this->resetRequ
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
分派()后如何获得响应?是为什么?它没有使用browser@max4ever
headersSentThrowsException
为真看起来不太好。在开发环境中使用浏览器时是否显示错误消息?不,至少在控制台中不显示。indexAjaxAction
提供JSON输出(return
或echo
)?我使用$this->\u helper->JSON($data);