Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / http-foundation / Tests / JsonResponseTest.php
index 8156da06939e435cd5209b415ee5f23237ed7f42..c8b93778954a8d4c4050a35f59fc15a54fbc06a8 100644 (file)
@@ -76,6 +76,19 @@ class JsonResponseTest extends TestCase
         $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);
@@ -186,6 +199,12 @@ class JsonResponseTest extends TestCase
         $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
      */
@@ -206,7 +225,6 @@ class JsonResponseTest extends TestCase
     /**
      * @expectedException \Exception
      * @expectedExceptionMessage This error is expected
-     * @requires PHP 5.4
      */
     public function testSetContentJsonSerializeError()
     {