$this->assertSame('application/vnd.acme.blog-v1+json', $response->headers->get('Content-Type'));
}
+ public function testSetJson()
+ {
+ $response = new JsonResponse('1', 200, array(), true);
+ $this->assertEquals('1', $response->getContent());
+
+ $response = new JsonResponse('[1]', 200, array(), true);
+ $this->assertEquals('[1]', $response->getContent());
+
+ $response = new JsonResponse(null, 200, array());
+ $response->setJson('true');
+ $this->assertEquals('true', $response->getContent());
+ }
+
public function testCreate()
{
$response = JsonResponse::create(array('foo' => 'bar'), 204);
$this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent());
}
+ public function testItAcceptsJsonAsString()
+ {
+ $response = JsonResponse::fromJsonString('{"foo":"bar"}');
+ $this->assertSame('{"foo":"bar"}', $response->getContent());
+ }
+
/**
* @expectedException \InvalidArgumentException
*/
/**
* @expectedException \Exception
* @expectedExceptionMessage This error is expected
- * @requires PHP 5.4
*/
public function testSetContentJsonSerializeError()
{