Fix warnings when php://output is used with ConsoleOutput.

The php://output stream is not compatible with posix functions.

Refs #4901
This commit is contained in:
mark_story 2015-01-25 22:24:24 -05:00
parent 4e33ef0386
commit a8ae12a700
2 changed files with 12 additions and 0 deletions

View file

@ -162,6 +162,7 @@ class ConsoleOutput {
$this->_output = fopen($stream, 'w');
if ((DS === '\\' && !(bool)env('ANSICON')) ||
$stream === 'php://output' ||
(function_exists('posix_isatty') && !posix_isatty($this->_output))
) {
$this->_outputAs = self::PLAIN;

View file

@ -231,6 +231,17 @@ class ConsoleOutputTest extends CakeTestCase {
$this->output->write('<error>Bad</error> Regular', false);
}
/**
* test plain output when php://output, as php://output is
* not compatible with posix_ functions.
*
* @return void
*/
public function testOutputAsPlainWhenOutputStream() {
$output = $this->getMock('ConsoleOutput', array('_write'), array('php://output'));
$this->assertEquals(ConsoleOutput::PLAIN, $output->outputAs());
}
/**
* test plain output only strips tags used for formatting.
*