public function stderr($msg, $status = self::STATUS_FAIL)
{
if (defined('STDERR')) {
fwrite(STDERR, $msg);
} else {
echo $msg;
if (count(\ob_get_status()) !== 0) {
ob_flush();
}
}
return $this;
}
public function testStdErrWithResource() { $fp = fopen('/tmp/stderr', 'w+'); define('STDERR', $fp); fclose($fp); $outputter = new Outputter(); $outputter->stderr('sending output', ''); $this->assertSame('sending output', trim(file_get_contents('/tmp/stderr'))); }