Skip to content

Commit fc8c324

Browse files
authored
Merge pull request #180 from Sam152/main
Fix #179 - assert difference between empty array and object.
2 parents 1866bcf + df4a040 commit fc8c324

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Drivers/JsonDriver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public function extension(): string
2929
public function match($expected, $actual)
3030
{
3131
if (is_string($actual)) {
32-
$actual = json_decode($actual, true, 512, JSON_THROW_ON_ERROR);
32+
$actual = json_decode($actual, false, 512, JSON_THROW_ON_ERROR);
3333
}
34-
$expected = json_decode($expected, true, 512, JSON_THROW_ON_ERROR);
34+
$expected = json_decode($expected, false, 512, JSON_THROW_ON_ERROR);
3535
Assert::assertJsonStringEqualsJsonString(json_encode($expected), json_encode($actual));
3636
}
3737
}

tests/Unit/Drivers/JsonDriverTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function it_can_not_serialize_resources()
134134
* ["null", "null", true]
135135
* ["1", "1", true]
136136
* ["1.1", "1.1", true]
137+
* ["{\"empty\": []}", "{\"empty\":{}}", false]
137138
*/
138139
public function it_can_match_json_strings(string $expected, string $actual, bool $assertion)
139140
{

0 commit comments

Comments
 (0)