bug #11272 [Console] Make sure formatter is the same. (akimsko)

This PR was submitted for the 2.5 branch but it was merged into the 2.3 branch instead (closes #11272).

Discussion
----------

[Console] Make sure formatter is the same.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |
The parent constructor will create a new formatter if the $formatter parameter is null.

This fix avoids that the formatter becomes 2 different instances in $this and $this->stderr, if null was passed to the constructor.

Commits
-------

64328d9 [Console] Make sure formatter is the same
This commit is contained in:
Fabien Potencier 2014-07-02 15:19:50 +02:00
commit 5f8ee9d596
2 changed files with 2 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter);
$this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $this->getFormatter());
}
/**

View File

@ -20,5 +20,6 @@ class ConsoleOutputTest extends \PHPUnit_Framework_TestCase
{
$output = new ConsoleOutput(Output::VERBOSITY_QUIET, true);
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
$this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
}
}