8000 Jsonresponse fix by kanariezwart · Pull Request #16551 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Jsonresponse fix #16551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[HttpFoundation] JsonResponse.php. Updated JsonResponseTest
  • Loading branch information
kanariezwart committed Nov 16, 2015
commit 1a1a089304d1178f5555cb8a704216589e7e767c
18 changes: 7 additions & 11 deletions src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,24 @@ public function testSetContentJsonSerializeError()
JsonResponse::create($serializable);
}

public function testSetDataAfterSettingEncodingOptions()
public function testDataAfterSettingEncodingOptions()
{
$response = new JsonResponse();
$response->setData(array(array(1, 2, 3)));

$this->assertEquals('[[1,2,3]]', $response->getContent());

$response->setEncodingOptions(JSON_FORCE_OBJECT);
$response->setData(array(array(4, 5, 6)));
$this->assertEquals('{"0":{"0":4,"1":5,"2":6}}', $response->getContent());

$this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent());
}

public function testSetContentAfterSettingEncodingOptions()
public function testContentAfterSettingEncodingOptionsToBeEmpty()
{
$response = new JsonResponse();
$response->setData(array(array(1, 2, 3)));

$this->assertEquals('[[1,2,3]]', $response->getContent());
$response->setContent('{"different":{"key":"value"}}');
$response->setEncodingOptions(JSON_FORCE_OBJECT);

$response->setEncodingOptions(JSON_PRETTY_PRINT);
$response->setContent("['baz' => ['foo' => 'bar']]");
$this->assertEquals("['baz' => ['foo' => 'bar']]", $response->getContent());
$this->assertEquals($response->getContent(), '{"different":{"key":"value"}}');
}
}

Expand Down
0