The Zend Tutorial lists many assertions to check the output generated by a request.
http://framework.zend.com/manual/en/zend.test.phpunit.html
But they all seem to assume that the output is html. I need to test json output instead.
Are there any assertions helpful to check json, or is there at least a generic way to make assertions against the output? Anything that doesn't rely on the request outputting html?
There are no assertion methods specific to JSON implemented in Zend_Test_PHPUnit. However, the first test you would might want to do is check that the JSON is valid, thus convert it to its original type (array/object). From then on you are in position to use PHPUnit's generic assertions to validate its contents.
UPDATE: To get the raw response body you can do the following (when extending Zend_Test_PHPUnit_ControllerTestCase):
$this->getResponse()->getBody();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With