Skip to content

Commit 66584f9

Browse files
committed
Fix inconsistent EOLs in JSON snapshots on Windows
It replaces OS dependent `PHP_EOL` with `\n`. `json_encode` with `JSON_PRETTY_PRINT` flag always use `\n` regardless of OS, but `PHP_EOL` yields `\r\n` on Windows causing inconsistent line ends and unnecessary diff for git, if files are regenerated.
1 parent 1194bcb commit 66584f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Drivers/JsonDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function serialize($data): string
1818
throw new CantBeSerialized('Resources can not be serialized to json');
1919
}
2020

21-
return json_encode($data, JSON_PRETTY_PRINT).PHP_EOL;
21+
return json_encode($data, JSON_PRETTY_PRINT)."\n";
2222
}
2323

2424
public function extension(): string
@@ -29,7 +29,7 @@ public function extension(): string
2929
public function match($expected, $actual)
3030
{
3131
if (is_array($actual)) {
32-
$actual = json_encode($actual, JSON_PRETTY_PRINT).PHP_EOL;
32+
$actual = json_encode($actual, JSON_PRETTY_PRINT)."\n";
3333
}
3434

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

0 commit comments

Comments
 (0)