diff --git a/src/Drivers/JsonDriver.php b/src/Drivers/JsonDriver.php index d77de4d..dc8841b 100644 --- a/src/Drivers/JsonDriver.php +++ b/src/Drivers/JsonDriver.php @@ -18,7 +18,7 @@ public function serialize($data): string throw new CantBeSerialized('Resources can not be serialized to json'); } - return json_encode($data, JSON_PRETTY_PRINT)."\n"; + return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n"; } public function extension(): string diff --git a/tests/Unit/Drivers/JsonDriverTest.php b/tests/Unit/Drivers/JsonDriverTest.php index 6b93051..2f95770 100644 --- a/tests/Unit/Drivers/JsonDriverTest.php +++ b/tests/Unit/Drivers/JsonDriverTest.php @@ -18,12 +18,12 @@ public function it_can_serialize_a_json_string_to_pretty_json() $expected = implode("\n", [ '{', - ' "foo": "bar"', + ' "foo": "bar/baz 😊"', '}', '', ]); - $this->assertEquals($expected, $driver->serialize('{"foo":"bar"}')); + $this->assertEquals($expected, $driver->serialize('{"foo":"bar\/baz \ud83d\ude0a"}')); } #[Test] @@ -135,6 +135,7 @@ public function it_can_not_serialize_resources() #[TestWith(['1', '1', true])] #[TestWith(['1.1', '1.1', true])] #[TestWith(['{"empty": []}', '{"empty":{}}', false])] + #[TestWith(['{"url": "foo\/bar😊"}', '{"url":"foo/bar\ud83d\ude0a"}', true])] public function it_can_match_json_strings(string $expected, string $actual, bool $assertion) { $driver = new JsonDriver;