bug #21981 [Console] Use proper line endings in BufferedOutput (julienfalque)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Use proper line endings in BufferedOutput

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

`BufferOutput` should be consistent with `StreamOutput` when writing newlines.

I faced an issue using this class in tests where the expected output was platform dependent (using `PHP_EOL` too).

Commits
-------

33946e69c0 Use proper line endings
This commit is contained in:
Fabien Potencier 2017-03-14 11:38:54 -07:00
commit 26198cf60a
2 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ class BufferedOutput extends Output
$this->buffer .= $message;
if ($newline) {
$this->buffer .= "\n";
$this->buffer .= PHP_EOL;
}
}
}

View File

@ -26,7 +26,7 @@ class DummyOutput extends BufferedOutput
public function getLogs()
{
$logs = array();
foreach (explode("\n", trim($this->fetch())) as $message) {
foreach (explode(PHP_EOL, trim($this->fetch())) as $message) {
preg_match('/^\[(.*)\] (.*)/', $message, $matches);
$logs[] = sprintf('%s %s', $matches[1], $matches[2]);
}