fix for issue #3657
ConsoleIO writing a message which contains end of lines characterspull/3685/head
parent
825b4b9c63
commit
bb0a2df293
|
@ -97,12 +97,14 @@ class ConsoleIO extends BaseIO
|
|||
{
|
||||
if (null !== $this->startTime) {
|
||||
$messages = (array) $messages;
|
||||
$messages[0] = sprintf(
|
||||
$messages = array_map(function (&$message) {
|
||||
return sprintf(
|
||||
'[%.1fMB/%.2fs] %s',
|
||||
memory_get_usage() / 1024 / 1024,
|
||||
microtime(true) - $this->startTime,
|
||||
$messages[0]
|
||||
$message
|
||||
);
|
||||
}, $messages);
|
||||
}
|
||||
$this->output->write($messages, $newline);
|
||||
$this->lastMessage = join($newline ? "\n" : '', (array) $messages);
|
||||
|
|
|
@ -49,6 +49,30 @@ class ConsoleIOTest extends TestCase
|
|||
$consoleIO->write('some information about something', false);
|
||||
}
|
||||
|
||||
public function testWriteWithMultipleLineStringWhenDebugging()
|
||||
{
|
||||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||
$outputMock->expects($this->once())
|
||||
->method('write')
|
||||
->with(
|
||||
$this->callback(function($messages){
|
||||
$this->assertRegExp("[(.*)/(.*) First line]", $messages[0]);
|
||||
$this->assertRegExp("[(.*)/(.*) Second line]", $messages[1]);
|
||||
return true;
|
||||
}),
|
||||
$this->equalTo(false)
|
||||
);
|
||||
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
||||
|
||||
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
|
||||
$startTime = microtime(true);
|
||||
$consoleIO->enableDebugging($startTime);
|
||||
|
||||
$example = explode('\n', 'First line\nSecond lines');
|
||||
$consoleIO->write($example, false);
|
||||
}
|
||||
|
||||
public function testOverwrite()
|
||||
{
|
||||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||
|
|
Loading…
Reference in New Issue