Skip to content

Commit 1194bcb

Browse files
committed
Use \n instead of OS dependent PHP_EOL in tests
`json_encode` with `JSON_PRETTY_PRINT` (and all other serialisation functions) always use `\n` regardless of OS, but since `PHP_EOL` is `\r\n` on Windows, `$expected` and `$actual` never can match if `PHP_EOL` used.
1 parent 160c495 commit 1194bcb

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

tests/Unit/Drivers/HtmlDriverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function it_can_serialize_a_html_string_to_pretty_html()
1313
{
1414
$driver = new HtmlDriver();
1515

16-
$expected = implode(PHP_EOL, [
16+
$expected = implode("\n", [
1717
'<!DOCTYPE html>',
1818
'<html lang="en">',
1919
'<head></head>',

tests/Unit/Drivers/JsonDriverTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function it_can_serialize_a_json_string_to_pretty_json()
1313
{
1414
$driver = new JsonDriver();
1515

16-
$expected = implode(PHP_EOL, [
16+
$expected = implode("\n", [
1717
'{',
1818
' "foo": "bar"',
1919
'}',
@@ -28,7 +28,7 @@ public function it_can_serialize_a_json_hash_to_pretty_json()
2828
{
2929
$driver = new JsonDriver();
3030

31-
$expected = implode(PHP_EOL, [
31+
$expected = implode("\n", [
3232
'{',
3333
' "foo": "FOO",',
3434
' "bar": "BAR",',
@@ -42,7 +42,7 @@ public function it_can_serialize_a_json_hash_to_pretty_json()
4242
'baz' => 'BAZ',
4343
]));
4444

45-
$expected = implode(PHP_EOL, [
45+
$expected = implode("\n", [
4646
'{',
4747
' "foo": "FOO",',
4848
' "bar": "BAR",',
@@ -74,7 +74,7 @@ public function it_can_serialize_a_json_array_to_pretty_json()
7474
{
7575
$driver = new JsonDriver();
7676

77-
$expected = implode(PHP_EOL, [
77+
$expected = implode("\n", [
7878
'[',
7979
' "foo",',
8080
' "bar",',
@@ -91,7 +91,7 @@ public function it_can_serialize_a_empty_json_object_to_pretty_json()
9191
{
9292
$driver = new JsonDriver();
9393

94-
$expected = implode(PHP_EOL, [
94+
$expected = implode("\n", [
9595
'{',
9696
' "foo": {',
9797
' "bar": true',

tests/Unit/Drivers/XmlDriverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function it_can_serialize_a_xml_string_to_pretty_xml()
1313
{
1414
$driver = new XmlDriver();
1515

16-
$expected = implode(PHP_EOL, [
16+
$expected = implode("\n", [
1717
'<?xml version="1.0"?>',
1818
'<foo>',
1919
' <bar>baz</bar>',

tests/Unit/Drivers/YamlDriverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function it_can_serialize_a_yaml_string()
1212
{
1313
$driver = new YamlDriver();
1414

15-
$yamlString = implode(PHP_EOL, [
15+
$yamlString = implode("\n", [
1616
'foo: bar',
1717
'baz: qux',
1818
'',
@@ -26,7 +26,7 @@ public function it_can_serialize_a_yaml_array()
2626
{
2727
$driver = new YamlDriver();
2828

29-
$expected = implode(PHP_EOL, [
29+
$expected = implode("\n", [
3030
'foo: bar',
3131
'baz: qux',
3232
'',

0 commit comments

Comments
 (0)