public function testReturnData() { $this->init(); \histou\Debug::enable(); $dashboard = new \histou\grafana\dashboard\DashboardInfluxDB('foo'); ob_start(); \histou\Basic::returnData($dashboard); $out1 = ob_get_contents(); ob_end_clean(); $this->assertSame($this->emptyDashboard, $out1); $_GET["callback"] = 1; ob_start(); \histou\Basic::returnData('{"foo":"bar"}'); $out2 = ob_get_contents(); ob_end_clean(); $this->assertSame('1({"foo":"bar"})', $out2); ob_start(); \histou\Basic::returnData(1); $out3 = ob_get_contents(); ob_end_clean(); $this->assertContains("<pre>Don't know what to do with this type: integer", $out3); }
public static function testConfig() { //test php command $cmd = static::$phpCommand . " -h 2>&1"; $process = proc_open($cmd, \histou\Basic::$descriptorSpec, $pipes); if (!is_resource($process)) { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard("# Error: Could not start: {$cmd}")); // @codeCoverageIgnore return 1; // @codeCoverageIgnore } stream_get_contents($pipes[1]); fclose($pipes[1]); $returnCode = proc_close($process); if ($returnCode != 0) { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard("# '" . $cmd . "' did not return with returncode 0. Maybe the phpCommand is not set properly."), 1); return 1; } return 0; }
foreach ($forecastTemplates as $ftemplate) { \histou\Debug::add($ftemplate); } \histou\Debug::add("Is the first ForecastTemplate valid: " . \histou\Debug::printBoolean($fValid) . "\n"); if ($fValid) { $forecastTemplate = $forecastTemplates[0]; $className = get_class($forecastTemplate); if ($className == 'histou\\template\\Rule') { $forecast = \histou\template\loader::loadForecastTemplate($forecastTemplate->getFileName(), true); } if (isset($forecast)) { $forecast->setForecastDurations(); } } if (isset($template) && !empty($template)) { $className = get_class($template); if ($className == 'histou\\template\\Rule') { $dashboard = \histou\template\loader::loadTemplate($template->getFileName(), true)->generateDashboard($perfData); } elseif ($className == 'histou\\template\\Template' || $className == 'histou\\template\\SimpleTemplate') { $dashboard = $template->generateDashboard($perfData); } else { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard("# unkown class {$className}"), 1); } if ($dashboard == null) { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# Template did not return a dashboard!'), 1); } else { \histou\Basic::returnData($dashboard, 0); } } else { \histou\Basic::returnData(\histou\Debug::errorMarkdownDashboard('# No template found!'), 1); }