8000 minor #43657 [Console] fix tests on Windows (xabbuh) · symfony/symfony@4612991 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4612991

Browse files
minor #43657 [Console] fix tests on Windows (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] fix tests on Windows | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Commits ------- 8c41e06 fix Console tests on Windows
2 parents 0a41bda + 8c41e06 commit 4612991

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

src/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ protected function getFormat()
2727

2828
protected function normalizeOutput($output)
2929
{
30-
return json_decode(parent::normalizeOutput($output), true);
30+
return array_map([$this, 'normalizeOutputRecursively'], json_decode($output, true));
31+
}
32+
33+
private function normalizeOutputRecursively($output)
34+
{
35+
if (\is_array($output)) {
36+
return array_map([$this, 'normalizeOutputRecursively'], $output);
37+
}
38+
39+
if (null === $output) {
40+
return null;
41+
}
42+
43+
return parent::normalizeOutput($output);
3144
}
3245
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0/10 [>---------------------------] 0%
2+
10/10 [============================] 100%
3+
4+
end of progressbar

src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ public function inputCommandToOutputFilesProvider()
8383
return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
8484
}
8585

86+
public function testOutputProgressIterate()
87+
{
88+
$code = require __DIR__.'/../Fixtures/Style/SymfonyStyle/progress/command_progress_iterate.php';
89+
90+
if ('\\' === \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
91+
$outputFilepath = __DIR__.'/../Fixtures/Style/SymfonyStyle/progress/output_progress_iterate_no_shade.txt';
92+
} else {
93+
$outputFilepath = __DIR__.'/../Fixtures/Style/SymfonyStyle/progress/output_progress_iterate_shade.txt';
94+
}
95+
96+
$this->command->setCode($code);
97+
$this->tester->execute([], ['interactive' => false, 'decorated' => false]);
98+
$this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true));
99+
}
100+
86101
public function testGetErrorStyle()
87102
{
88103
$input = $this->createMock(InputInterface::class);

0 commit comments

Comments
 (0)
0