[Console] Fix SymfonyQuestionHelper tests sometimes failing on AppVeyor

This commit is contained in:
Thomas Calvet 2020-01-09 19:48:50 +01:00
parent 416f0abf99
commit 474f3bef08

View File

@ -145,13 +145,13 @@ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest
); );
$this->assertOutputContains(<<<EOT $this->assertOutputContains(<<<EOT
qqq: qqq:
[foo ] foo [foo ] foo
[żółw ] bar [żółw ] bar
[łabądź] baz [łabądź] baz
> >
EOT EOT
, $output); , $output, true);
} }
public function testChoiceQuestionCustomPrompt() public function testChoiceQuestionCustomPrompt()
@ -168,9 +168,9 @@ EOT
$this->assertOutputContains(<<<EOT $this->assertOutputContains(<<<EOT
qqq: qqq:
[0] foo [0] foo
>ccc> >ccc>
EOT EOT
, $output); , $output, true);
} }
protected function getInputStream($input) protected function getInputStream($input)
@ -200,10 +200,15 @@ EOT
return $mock; return $mock;
} }
private function assertOutputContains($expected, StreamOutput $output) private function assertOutputContains($expected, StreamOutput $output, $normalize = false)
{ {
rewind($output->getStream()); rewind($output->getStream());
$stream = stream_get_contents($output->getStream()); $stream = stream_get_contents($output->getStream());
if ($normalize) {
$stream = str_replace(PHP_EOL, "\n", $stream);
}
$this->assertStringContainsString($expected, $stream); $this->assertStringContainsString($expected, $stream);
} }
} }