i have a problem with writing tests for my action that gets called by jquery via ajax. i don't know how to catch the data that is being sent back to the view, by the action, so that i could assert if it's correct. my $.ajax(...) script inserts result, echo-ed by the controller, into a textarea element, but in my test script, result is null. failure message:
Failed asserting that null matches expected '...
here's what my test code so far:
$this->getRequest()->setRawBody('some json containing input params im testing');
$this->getRequest()->setMethod('GET');
$this->getRequest->setHeader('HTTP_X_REQUESTED_WITH','XMLHttpRequest');
$this->dispatch('my url');
$result = json_decode($this->getResponse()->getBody(),true);
$expectedResult = 'some string';
$this->assertEquals($expectedResult, $result['targeted element']);
$this->_helper->json($data);which will encode data, disable layout and view and set propper headers.