diff --git a/src/Symfony/Component/Console/Tester/TesterTrait.php b/src/Symfony/Component/Console/Tester/TesterTrait.php index 1ab7a70aa22d9..238c7b7ebbf98 100644 --- a/src/Symfony/Component/Console/Tester/TesterTrait.php +++ b/src/Symfony/Component/Console/Tester/TesterTrait.php @@ -168,7 +168,11 @@ private static function createStream(array $inputs) $stream = fopen('php://memory', 'r+', false); foreach ($inputs as $input) { - fwrite($stream, $input.\PHP_EOL); + fwrite($stream, $input); + + if (!str_ends_with($input, "\x4")) { + fwrite($stream, \PHP_EOL); + } } rewind($stream); diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index b974f942abb49..799618a1ecc52 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -136,7 +136,7 @@ public function testCommandWithMultilineInputs() $command = new Command('foo'); $command->setHelperSet(new HelperSet([new QuestionHelper()])); $command->setCode(function (InputInterface $input, OutputInterface $output) use ($question, $command): int { - $output->write($command->getHelper('question')->ask($input, $output, (new Question($question."\n"))->setMultiline(true))); + $output->write($command->getHelper('question')->ask($input, $output, (new Question($question))->setMultiline(true))); $output->write(stream_get_contents($input->getStream())); return 0; @@ -152,7 +152,7 @@ public function testCommandWithMultilineInputs() $tester->execute([]); $tester->assertCommandIsSuccessful(); - $this->assertSame($question."\n".$address."\n".$address."\n", $tester->getDisplay()); + $this->assertSame($question.$address.$address.\PHP_EOL, $tester->getDisplay()); } public function testCommandWithDefaultInputs()