public function testBasics() { $this->assertSame(\histou\Debug::isEnable(), false); \histou\Debug::enable(); $this->assertSame(\histou\Debug::isEnable(), true); $this->assertSame(\histou\Debug::printBoolean(true), "true"); $this->assertSame(\histou\Debug::printBoolean(false), "false"); \histou\Debug::add("foo"); $this->assertSame("#### foo\n", \histou\Debug::getLogAsMarkdown()); \histou\Debug::add("bar"); $this->assertSame("#### foo\n#### bar\n", \histou\Debug::getLogAsMarkdown()); }
public function testParseArgs() { $this->testParseIniInflux(); $_GET['host'] = "host0"; $_GET['service'] = "service0"; $_GET['debug'] = "true"; $_GET['height'] = "500px"; $_GET['legend'] = "false"; $_GET['annotations'] = "true"; \histou\Basic::parsArgs(); $this->assertSame("host0", HOST); $this->assertSame("service0", SERVICE); $this->assertSame(true, \histou\Debug::isEnable()); $this->assertSame("500px", \histou\Basic::$height); $this->assertSame(false, SHOW_LEGEND); $this->assertSame(true, SHOW_ANNOTATION); }
/** This function will print its input and exit with the given returncode. @param object $data This object will be converted to json. @param int $returnCode The returncode the programm will exit. @return null. **/ public static function returnData($data, $returnCode = 0) { if (is_object($data) && is_subclass_of($data, 'histou\\grafana\\dashboard\\Dashboard')) { if (\histou\Debug::isEnable()) { //$data->addRow(\histou\Debug::genMarkdownRow(\histou\Debug::getLogAsMarkdown(), 'Debug')); //for markdown $data->addRow(\histou\Debug::genRow(\histou\Debug::getLog())); } $data = $data->toArray(); $json = json_encode($data); } elseif (is_string($data)) { $json = $data; } else { echo '<pre>'; print_r("Don't know what to do with this type: " . gettype($data)); var_dump($data); echo '</pre>'; } if (isset($json)) { if (isset($_GET["callback"]) && !empty($_GET["callback"])) { header('content-type: application/json; charset=utf-8'); echo "{$_GET['callback']}({$json})"; } else { echo "<pre>"; print_r($data); echo "<br>"; print_r($returnCode); echo "<br>"; print_r($json); echo "<br>"; echo "</pre>"; } } }