8000 [Console] ConsoleOuput::isDecorated is detected from STDOUT · symfony/symfony@df1ee7f · GitHub
[go: up one dir, main page]

Skip to content

Commit df1ee7f

Browse files
committed
[Console] ConsoleOuput::isDecorated is detected from STDOUT
1 parent 7be7e62 commit df1ee7f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Symfony/Component/Console/Output/ConsoleOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = nu
5050

5151
parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
5252

53-
$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $this->getFormatter());
53+
$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $this->getFormatter()->isDecorated(), $this->getFormatter());
5454
}
5555

5656
/**

src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414
use Symfony\Component\Console\Output\ConsoleOutput;
1515
use Symfony\Component\Console\Output\Output;
1616

17+
class ConsoleOutputWithColorSupportDifferentFromStderr extends ConsoleOutput
18+
{
19+
public $expected;
20+
21+
protected function hasColorSupport()
22+
{
23+
// emulate posix_isatty(STDOUT) !== posix_isatty(STDERR)
24+
return ($this->expected = ! parent::hasColorSupport());
25+
}
26+
27+
public function getUnexpectedValue()
28+
{
29+
return parent::hasColorSupport();
30+
}
31+
}
32+
1733
class ConsoleOutputTest extends \PHPUnit_Framework_TestCase
1834
{
1935
public function testConstructor()
@@ -22,4 +38,11 @@ public function testConstructor()
2238
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
2339
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
2440
}
41+
42+
public function testDecoratedIsNotOverriddenByStderr()
43+
{
44+
$output = new ConsoleOutputWithColorSupportDifferentFromStderr(Output::VERBOSITY_QUIET, null);
45+
46+
$this->assertSame($output->expected, $output->isDecorated());
47+
}
2548
}

0 commit comments

Comments
 (0)
0