/** * Contains the logic to render a report and its children to the command line * * @param common_report_Report $report A report to be rendered. * @param boolean $useColor * @param integer $intend the intend of the message. * @return string The shell output of $report. */ public static function renderToCommandLine(common_report_Report $report, $useColor = self::AUTOSENSE, $intend = 0) { switch ($report->getType()) { case common_report_Report::TYPE_SUCCESS: $color = '0;32'; // green break; case common_report_Report::TYPE_WARNING: $color = '1;33'; // yellow break; case common_report_Report::TYPE_ERROR: $color = '1;31'; // red break; default: $color = '0;37'; // light grey } if ($useColor == self::AUTOSENSE) { $useColor = getenv('TAO_CONSOLE') !== 'nocolor' && !helpers_PlatformInstance::isWindows(); } $output = ($useColor ? "[" . $color . 'm' : '') . ($intend > 0 ? str_repeat(' ', $intend) : '') . $report->getMessage() . ($useColor ? "[0m" : '') . PHP_EOL; foreach ($report as $child) { $output .= self::renderToCommandline($child, $useColor, $intend + 2); } return $output; }
public function testBasicReport() { $report = new common_report_Report(common_report_Report::TYPE_SUCCESS, 'test message'); $this->assertFalse($report->hasChildren()); $this->assertEquals('test message', (string) $report); $this->assertEquals('test message', $report->getMessage()); $this->assertEquals(common_report_Report::TYPE_SUCCESS, $report->getType()); foreach ($report as $child) { $this->fail('Should not contain children'); } }
/** * Contains the logic to render a report and its children to the command line * * @param common_report_Report $report A report to be rendered. * @param integer $intend the intend of the message. * @return string The HTML output of $report. */ public static function renderToCommandline(common_report_Report $report, $intend = 0) { switch ($report->getType()) { case common_report_Report::TYPE_SUCCESS: $color = '0;32'; // green break; case common_report_Report::TYPE_WARNING: $color = '1;33'; // yellow break; case common_report_Report::TYPE_ERROR: $color = '1;31'; // red break; default: $color = '0;37'; // light grey } $output = "[" . $color . 'm' . ($intend > 0 ? str_repeat(' ', $intend) : '') . $report->getMessage() . "[0m" . PHP_EOL; foreach ($report as $child) { $output .= self::renderToCommandline($child, $intend + 2); } return $output; }
/** * Returns a report * * @param common_report_Report $report */ protected function returnReport(common_report_Report $report, $refresh = true) { if ($refresh) { $data = $report->getdata(); if ($report->getType() == common_report_Report::TYPE_SUCCESS && !is_null($data) && $data instanceof \core_kernel_classes_Resource) { $this->setData('message', $report->getMessage()); $this->setData('selectNode', tao_helpers_Uri::encode($data->getUri())); $this->setData('reload', true); return $this->setView('form.tpl', 'tao'); } } $this->setData('report', $report); $this->setView('report.tpl', 'tao'); }