8000 [Console] Display errors even when --quiet is present · symfony/symfony@dbe85df · GitHub
[go: up one dir, main page]

Skip to content

Commit dbe85df

Browse files
committed
[Console] Display errors even when --quiet is present
When using SymfonyStyle::error the message should be printed even when the --quiet option is used.
1 parent a06e564 commit dbe85df

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function block($messages, ?string $type = null, ?string $style = null, st
6464
$messages = \is_array($messages) ? array_values($messages) : [$messages];
6565

6666
$this->autoPrependBlock();
67-
$this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape));
67+
$this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape),
68+
self::OUTPUT_NORMAL|($type == 'ERROR' ? self::VERBOSITY_QUIET : 0));
6869
$this->newLine();
6970
}
7071

src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php

+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,24 @@ public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable(
115115

116116
$this->assertInstanceOf(SymfonyStyle::class, $style->getErrorStyle());
117117
}
118+
119+
public function testPrintErrorIfWeRunInQuietMode()
120+
{
121+
$output = $this->getMockBuilder(OutputInterface::class)->getMock();
122+
$output
123+
->method('getFormatter')
124+
->willReturn(new OutputFormatter());
125+
$output
126+
->expects($this->once())
127+
->method('writeln')
128+
->with(
129+
$this->anything(),
130+
$this->callback(function($type)
131+
{
132+
return (($type & OutputInterface::VERBOSITY_QUIET) == OutputInterface::VERBOSITY_QUIET) ? true:false;
133+
}
134+
));
135+
$style = new SymfonyStyle($this->getMockBuilder(InputInterface::class)->getMock(), $output);
136+
$style->error('test');
137+
}
118138
}

0 commit comments

Comments
 (0)
0