Skip to content

Commit 43404db

Browse files
Luke Renfrewacbramley
authored andcommitted
Added test to check the JSON driver can take an array.
Resolved the Json driver using the wrong variable.
1 parent 806539f commit 43404db

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Drivers/JsonDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function extension(): string
2929
public function match($expected, $actual)
3030
{
3131
if (is_array($actual)) {
32-
$actual = json_encode($data, JSON_PRETTY_PRINT).PHP_EOL;
32+
$actual = json_encode($actual, JSON_PRETTY_PRINT).PHP_EOL;
3333
}
3434

3535
Assert::assertJsonStringEqualsJsonString($expected, $actual);

tests/Integration/AssertionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ public function can_match_a_json_snapshot()
4141
$this->assertMatchesJsonSnapshot($data);
4242
}
4343

44+
/** @test */
45+
public function can_match_an_array_snapshot()
46+
{
47+
$data = ['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'];
48+
49+
$this->assertMatchesJsonSnapshot($data);
50+
}
51+
4452
/** @test */
4553
public function can_match_a_file_hash_snapshot()
4654
{

0 commit comments

Comments
 (0)