You are here

public function JsonResponseTest::testSetEncodingOptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/JsonResponseTest.php \Symfony\Component\HttpFoundation\Tests\JsonResponseTest::testSetEncodingOptions()

File

vendor/symfony/http-foundation/Tests/JsonResponseTest.php, line 176

Class

JsonResponseTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testSetEncodingOptions() {
  $response = new JsonResponse();
  $response
    ->setData(array(
    array(
      1,
      2,
      3,
    ),
  ));
  $this
    ->assertEquals('[[1,2,3]]', $response
    ->getContent());
  $response
    ->setEncodingOptions(JSON_FORCE_OBJECT);
  $this
    ->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response
    ->getContent());
}