$inputStream =
fopen('php://memory', 'r+', false
);
fwrite($inputStream, "Batman & Robin\n"
);
rewind($inputStream);
$input =
$this->
createMock(StreamableInputInterface::
class);
$input->
expects($this->
once())->
method('isInteractive'
)->
willReturn(true
);
$input->
expects($this->
once())->
method('getStream'
)->
willReturn($inputStream);
$sections =
[];
$output =
new ConsoleSectionOutput($this->stream,
$sections, OutputInterface::VERBOSITY_NORMAL, true,
new OutputFormatter());
(new QuestionHelper())->
ask($input,
$output,
new Question('What\'s your favorite super hero?'
));
$output->
clear();
rewind($output->
getStream());
$this->
assertSame('What\'s your favorite super hero?'.\PHP_EOL."\x1b[2A\x1b[0J",
stream_get_contents($output->
getStream()));
} public function testWriteWithoutNewLine() { $sections =
[];
$output =
new ConsoleSectionOutput($this->stream,
$sections, OutputInterface::VERBOSITY_NORMAL, true,
new OutputFormatter());