I am trying to call a page that returns JSON. This is the response sent by the controller
$response = new JsonResponse();
$response->setData($result);
$response->send();
exit;
When I test it with phpunit, with this code:
$publicClient = static::createClient();
$publicClient->request('POST', '/list/', []);
$this->assertTrue(true);
the assert is never reached. Instead the ouptut (with --debug and -v) is simply
bin/phpunit -c app/phpunit.xml.dist --debug -v
PHPUnit 4.3.4 by Sebastian Bergmann.
Configuration read from /var/www/eliphi/public_html/app/phpunit.xml.dist
Starting test '[...]\Tests\Controller\FrontendControllerTest::testListAjax'.
[{"seriesTitle":"public","publications":[]},{"seriesTitle":"member","publications":[]},{"seriesTitle":"abo","publications":[]},{"seriesTitle":"public Magazine","publications":[]},{"seriesTitle":"member Magazine","publications":[]},{"seriesTitle":"abo Magazine","publications":[]}]
That's all! When I call the page from the browser, the response header is correctly set with
Date: Sat, 01 Nov 2014 14:56:31 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.34-1+deb.sury.org~precise+1
Cache-Control: no-cache
Connection: close
Content-Type: application/json
200 OK
If I do a request on a different url that returns html, it works just fine. What could possibly be the reason for this?