You are here

public function JsonEncoderTest::testOptions in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/serializer/Tests/Encoder/JsonEncoderTest.php \Symfony\Component\Serializer\Tests\Encoder\JsonEncoderTest::testOptions()

File

vendor/symfony/serializer/Tests/Encoder/JsonEncoderTest.php, line 45

Class

JsonEncoderTest

Namespace

Symfony\Component\Serializer\Tests\Encoder

Code

public function testOptions() {
  $context = array(
    'json_encode_options' => JSON_NUMERIC_CHECK,
  );
  $arr = array();
  $arr['foo'] = '3';
  $expected = '{"foo":3}';
  $this
    ->assertEquals($expected, $this->serializer
    ->serialize($arr, 'json', $context));
  $arr = array();
  $arr['foo'] = '3';
  $expected = '{"foo":"3"}';
  $this
    ->assertEquals($expected, $this->serializer
    ->serialize($arr, 'json'), 'Context should not be persistent');
}