From 52928bb1df18a57ad318766be4067fd93141be75 Mon Sep 17 00:00:00 2001 From: Sammyjo20 <29132017+Sammyjo20@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:52:05 +0000 Subject: [PATCH] Feature | V3 Pretty Print Fixtures & Cached Responses --- src/Data/RecordedResponse.php | 2 +- tests/Unit/FixtureDataTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Data/RecordedResponse.php b/src/Data/RecordedResponse.php index 511027e0..0c524cd1 100644 --- a/src/Data/RecordedResponse.php +++ b/src/Data/RecordedResponse.php @@ -71,7 +71,7 @@ public static function fromResponse(Response $response): static */ public function toFile(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + return json_encode($this, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT); } /** diff --git a/tests/Unit/FixtureDataTest.php b/tests/Unit/FixtureDataTest.php index f84238c5..c2ed998e 100644 --- a/tests/Unit/FixtureDataTest.php +++ b/tests/Unit/FixtureDataTest.php @@ -53,10 +53,10 @@ ], ]; - $fixtureData = RecordedResponse::fromFile(json_encode($data)); + $fixtureData = RecordedResponse::fromFile(json_encode($data, JSON_PRETTY_PRINT)); - $serialized = json_encode($fixtureData); + $serialized = json_encode($fixtureData, JSON_PRETTY_PRINT); - expect($serialized)->toEqual(json_encode($data)); + expect($serialized)->toEqual(json_encode($data, JSON_PRETTY_PRINT)); expect($fixtureData->toFile())->toEqual($serialized); });