Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d36330

Browse files
[Console] Don’t append a new line to test inputs ending with an EOT
1 parent 78a6b2b commit 7d36330

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

‎Tester/TesterTrait.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ private static function createStream(array $inputs)
168168
$stream = fopen('php://memory', 'r+', false);
169169

170170
foreach ($inputs as $input) {
171-
fwrite($stream, $input.\PHP_EOL);
171+
fwrite($stream, $input);
172+
173+
if (!str_ends_with($input, "\x4")) {
174+
fwrite($stream, \PHP_EOL);
175+
}
172176
}
173177

174178
rewind($stream);

‎Tests/Tester/CommandTesterTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function testCommandWithMultilineInputs()
136136
$command = new Command('foo');
137137
$command->setHelperSet(new HelperSet([new QuestionHelper()]));
138138
$command->setCode(function (InputInterface $input, OutputInterface $output) use ($question, $command): int {
139-
$output->write($command->getHelper('question')->ask($input, $output, (new Question($question."\n"))->setMultiline(true)));
139+
$output->write($command->getHelper('question')->ask($input, $output, (new Question($question))->setMultiline(true)));
140140
$output->write(stream_get_contents($input->getStream()));
141141

142142
return 0;
@@ -152,7 +152,7 @@ public function testCommandWithMultilineInputs()
152152
$tester->execute([]);
153153

154154
$tester->assertCommandIsSuccessful();
155-
$this->assertSame($question."\n".$address."\n".$address."\n", $tester->getDisplay());
155+
$this->assertSame($question.$address.$address.\PHP_EOL, $tester->getDisplay());
156156
}
157157

158158
public function testCommandWithDefaultInputs()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /