Skip to content

Commit 61f8bca

Browse files
committedMay 20, 2020
Make tests pass on Windows platform
1 parent ede5984 commit 61f8bca

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
#operating-system: [ubuntu-latest, windows-latest, macos-latest]
15-
operating-system: [ubuntu-latest, macos-latest]
14+
operating-system: [ubuntu-latest, windows-latest, macos-latest]
1615
php-versions: ['7.2', '7.3', '7.4']
1716
runs-on: ${{ matrix.operating-system }}
1817

‎tests/TestHelper.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,31 @@ public static function makePattern(
112112
*/
113113
public static function makeArrayOutput(array $entries): string
114114
{
115-
$output = '';
116-
foreach ($entries as $key => $value) {
117-
$output .= <<<EOT
118-
[{$key}] => {$value}
119-
120-
EOT;
121-
}
122-
$output = rtrim($output);
123-
124-
return <<<EOT
115+
$output = preg_replace('/\R/', "\n", str_replace(
116+
'{{entries}}',
117+
implode(PHP_EOL, array_map(
118+
function ($key, $value): string {
119+
return " [{$key}] => {$value}";
120+
},
121+
array_keys($entries),
122+
array_values($entries)
123+
)),
124+
<<<'EOT'
125125
Array
126126
(
127-
{$output}
127+
{{entries}}
128128
)
129129

130-
EOT;
130+
EOT
131+
));
132+
133+
if ($output === null) {
134+
throw new \UnexpectedValueException(
135+
'Error while replacing newlines in array output'
136+
);
137+
}
138+
139+
return $output;
131140
}
132141

133142
/**

0 commit comments

Comments
 (0)
Please sign in to comment.