From 43404dbcf2b6e2d84b3c209ad68f996f3319a621 Mon Sep 17 00:00:00 2001 From: Luke Renfrew Date: Thu, 7 Feb 2019 14:20:07 +0000 Subject: [PATCH 1/2] Added test to check the JSON driver can take an array. Resolved the Json driver using the wrong variable. --- src/Drivers/JsonDriver.php | 2 +- tests/Integration/AssertionTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Drivers/JsonDriver.php b/src/Drivers/JsonDriver.php index 253bdd6..41e22cd 100644 --- a/src/Drivers/JsonDriver.php +++ b/src/Drivers/JsonDriver.php @@ -29,7 +29,7 @@ public function extension(): string public function match($expected, $actual) { if (is_array($actual)) { - $actual = json_encode($data, JSON_PRETTY_PRINT).PHP_EOL; + $actual = json_encode($actual, JSON_PRETTY_PRINT).PHP_EOL; } Assert::assertJsonStringEqualsJsonString($expected, $actual); diff --git a/tests/Integration/AssertionTest.php b/tests/Integration/AssertionTest.php index 0367050..6f6513b 100644 --- a/tests/Integration/AssertionTest.php +++ b/tests/Integration/AssertionTest.php @@ -41,6 +41,14 @@ public function can_match_a_json_snapshot() $this->assertMatchesJsonSnapshot($data); } + /** @test */ + public function can_match_an_array_snapshot() + { + $data = ['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']; + + $this->assertMatchesJsonSnapshot($data); + } + /** @test */ public function can_match_a_file_hash_snapshot() { From b237c40d4b7ffdb824b75d30169070772acd2e96 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: 2019年5月13日 08:15:55 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df25458..6ccbbf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to `phpunit-snapshot-assertions` will be documented in this file +## 1.4.2 - 2019年05月13日 +- Fix JSON driver + ## 1.4.1 - 2019年01月29日 - Fix JSON array comparisons

AltStyle によって変換されたページ (->オリジナル) /