Skip to content

Commit f56a642

Browse files
authored
Fix PHPUnit (#54)
Trims the trailing spaces of CLI display strings to avoid platform/php-config specific tests.
1 parent 9c7c1c5 commit f56a642

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

tests/Console/Command/AddPrefixCommandIntegrationTest.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,21 @@ public function test_scope_in_normal_mode()
134134

135135
$expected = <<<'EOF'
136136
137-
____ __ ______ _____
137+
____ __ ______ _____
138138
/ __ \/ / / / __ \ / ___/_________ ____ ___ _____
139139
/ /_/ / /_/ / /_/ / \__ \/ ___/ __ \/ __ \/ _ \/ ___/
140-
/ ____/ __ / ____/ ___/ / /__/ /_/ / /_/ / __/ /
141-
/_/ /_/ /_/_/ /____/\___/\____/ .___/\___/_/
140+
/ ____/ __ / ____/ ___/ / /__/ /_/ / /_/ / __/ /
141+
/_/ /_/ /_/_/ /____/\___/\____/ .___/\___/_/
142142
/_/
143143
144144
PHP Scoper version 12ccf1ac8c7ae8eaf502bd30f95630a112dc713f
145145
146146
0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0%
147147
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
148148
149-
[OK] Successfully prefixed 1 files.
149+
[OK] Successfully prefixed 1 files.
150150
151-
// Memory usage: 5.00MB (peak: 10.00MB), time: 0.00s
151+
// Memory usage: 5.00MB (peak: 10.00MB), time: 0.00s
152152

153153

154154
EOF;
@@ -176,21 +176,21 @@ public function test_scope_in_verbose_mode()
176176

177177
$expected = <<<'EOF'
178178
179-
____ __ ______ _____
179+
____ __ ______ _____
180180
/ __ \/ / / / __ \ / ___/_________ ____ ___ _____
181181
/ /_/ / /_/ / /_/ / \__ \/ ___/ __ \/ __ \/ _ \/ ___/
182-
/ ____/ __ / ____/ ___/ / /__/ /_/ / /_/ / __/ /
183-
/_/ /_/ /_/_/ /____/\___/\____/ .___/\___/_/
182+
/ ____/ __ / ____/ ___/ / /__/ /_/ / /_/ / __/ /
183+
/_/ /_/ /_/_/ /____/\___/\____/ .___/\___/_/
184184
/_/
185185
186186
PHP Scoper version 12ccf1ac8c7ae8eaf502bd30f95630a112dc713f
187187
188188
* [OK] /path/to/file.php
189189
190190
191-
[OK] Successfully prefixed 1 files.
191+
[OK] Successfully prefixed 1 files.
192192
193-
// Memory usage: 5.00MB (peak: 10.00MB), time: 0.00s
193+
// Memory usage: 5.00MB (peak: 10.00MB), time: 0.00s
194194

195195

196196
EOF;
@@ -211,11 +211,20 @@ private function getNormalizeDisplay(string $display)
211211
$display
212212
);
213213

214-
return preg_replace(
214+
$display = preg_replace(
215215
'/(dev-)?\b([a-f0-9]{40})\b/',
216216
'12ccf1ac8c7ae8eaf502bd30f95630a112dc713f',
217217
$display
218218
);
219+
220+
$lines = explode("\n", $display);
221+
222+
$lines = array_map(
223+
'rtrim',
224+
$lines
225+
);
226+
227+
return implode("\n", $lines);
219228
}
220229

221230
private function assertFilesAreSame(string $expectedDir, string $actualDir)

0 commit comments

Comments
 (0)