| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class JsonSerializerOptionsTest extends TestCase |
||
| 11 | { |
||
| 12 | |||
| 13 | public function test_default_options() |
||
| 14 | { |
||
| 15 | $expected = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_SLASHES; |
||
| 16 | |||
| 17 | $this->assertAttributeEquals($expected, 'options', new JsonSerializer); |
||
| 18 | } |
||
| 19 | |||
| 20 | public function test_adding_options() |
||
| 21 | { |
||
| 22 | $expected = JSON_PRESERVE_ZERO_FRACTION |
||
| 23 | | JSON_UNESCAPED_SLASHES |
||
| 24 | | JSON_PRETTY_PRINT |
||
| 25 | | JSON_ERROR_INF_OR_NAN; |
||
| 26 | |||
| 27 | $this->assertAttributeEquals($expected, 'options', new JsonSerializer(JSON_ERROR_INF_OR_NAN | JSON_PRETTY_PRINT)); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function test_excluding_options() |
||
| 31 | { |
||
| 32 | $expected = 0; |
||
| 33 | |||
| 34 | $this->assertAttributeEquals($expected, 'options', new JsonSerializer( |
||
| 35 | JSON_UNESCAPED_SLASHES ^ JSON_PRESERVE_ZERO_FRACTION |
||
| 36 | )); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function test_include_and_exclude_options() |
||
| 40 | { |
||
| 41 | $expected = JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; |
||
| 42 | |||
| 43 | $this->assertAttributeEquals($expected, 'options', new JsonSerializer( |
||
| 44 | JSON_UNESCAPED_UNICODE ^ JSON_PRESERVE_ZERO_FRACTION | JSON_NUMERIC_CHECK |
||
| 45 | ), 'Adds JSON_UNESCAPED_UNICODE and JSON_NUMERIC_CHECK -- removes JSON_PRESERVE_ZERO_FRACTION'); |
||
| 46 | } |
||
| 48 |