public function JsonEncoderTest::testOptions

File

drupal/core/vendor/symfony/serializer/Symfony/Component/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');
}