diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index 0d32763a0ff4f..a9c35931f37d9 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -64,7 +64,8 @@ public function block($messages, ?string $type = null, ?string $style = null, st $messages = \is_array($messages) ? array_values($messages) : [$messages]; $this->autoPrependBlock(); - $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape)); + $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape), + self::OUTPUT_NORMAL | ('ERROR' == $type ? self::VERBOSITY_QUIET : 0)); $this->newLine(); } diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php index 943b94172a609..32adae1acf983 100644 --- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php @@ -115,4 +115,23 @@ public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable( $this->assertInstanceOf(SymfonyStyle::class, $style->getErrorStyle()); } + + public function testPrintErrorIfWeRunInQuietMode() + { + $output = $this->getMockBuilder(OutputInterface::class)->getMock(); + $output + ->method('getFormatter') + ->willReturn(new OutputFormatter()); + $output + ->expects($this->once()) + ->method('writeln') + ->with( + $this->anything(), + $this->callback(function ($type) { + return (OutputInterface::VERBOSITY_QUIET == ($type & OutputInterface::VERBOSITY_QUIET)) ? true : false; + } + )); + $style = new SymfonyStyle($this->getMockBuilder(InputInterface::class)->getMock(), $output); + $style->error('test'); + } }