/**
  * @covers WeatherMap::processString
  */
 public function testProcessString()
 {
     global $weathermap_debugging;
     $this->assertEquals("", $this->object->processString("", $this->object, true, false));
     $this->assertEquals("dog", $this->object->processString("dog", $this->object, true, false));
     $this->assertEquals("[UNKNOWN]", $this->object->processString("{map:randomstring}", $this->object, true, false));
     $this->assertEquals("[UNKNOWN]", $this->object->processString("{node:randomstring}", $this->object, true, false));
     $this->assertEquals("[UNKNOWN]", $this->object->processString("{link:randomstring}", $this->object, true, false));
     // load a config file, so there are map objects to talk about
     $this->object->ReadConfig(dirname(__FILE__) . '/../../test-suite/tests/simple-link-1.conf');
     // initialise the data, otherwise we'll get "" instead of 0 for bandwidth, etc
     $this->object->readData();
     $n1 = $this->object->nodes['n1'];
     $l1 = $this->object->links['l1'];
     $this->assertInstanceOf("WeatherMapNode", $n1);
     $this->assertInstanceOf("WeatherMapLink", $l1);
     // $weathermap_debugging = TRUE;
     $n1->add_note("note1", "Data from another plugin");
     $n1->add_hint("note2", "User input");
     // testing notes-inclusion/exclusion
     $this->assertEquals("[UNKNOWN]", $this->object->processString("{node:this:note1}", $n1, false, false));
     $this->assertEquals("Data from another plugin", $this->object->processString("{node:this:note1}", $n1, true, false));
     // vs hints, which always work
     $this->assertEquals("User input", $this->object->processString("{node:this:note2}", $n1, false, false));
     $this->assertEquals("User input", $this->object->processString("{node:this:note2}", $n1, true, false));
     $this->assertEquals("Some Simple Links and Nodes", $this->object->processString("{map:title}", $n1, true, false));
     $this->assertEquals("Some Simple Links and Nodes", $this->object->processString("{map:title}", $this->object, true, false));
     $this->assertEquals("Some Simple Links and Nodes", $this->object->processString("{map:title}", $l1, true, false));
     // hints "overwrite" internal variables
     $this->object->add_hint("title", "fish");
     $this->assertEquals("fish", $this->object->processString("{map:title}", $n1, true, false));
     // and notes might "overwrite" internal variables depending on where we are (not in TARGETs for example)
     $this->object->delete_hint("title");
     $this->object->add_note("title", "cat");
     $this->assertEquals("cat", $this->object->processString("{map:title}", $n1, true, false));
     $this->assertEquals("Some Simple Links and Nodes", $this->object->processString("{map:title}", $n1, false, false));
     $this->assertEquals("n1", $this->object->processString("{node:this:name}", $n1, true, false));
     $this->assertEquals("l1", $this->object->processString("{link:this:name}", $l1, true, false));
     $this->assertEquals("0", $this->object->processString("{node:this:bandwidth_in}", $n1, true, false));
     $this->assertEquals("0", $this->object->processString("{link:this:bandwidth_in}", $l1, true, false));
     $this->assertEquals("0", $this->object->processString("{node:n1:bandwidth_in}", $this->object, true, false));
     $this->assertEquals("0", $this->object->processString("{link:l1:bandwidth_in}", $this->object, true, false));
 }
/**
 * Produce the HTML output for both the unit-tests and the CLI utility
 *
 * @global string $WEATHERMAP_VERSION
 * @param string $htmlfile
 * @param WeatherMap $map
 */
function OutputHTML($htmlfile, &$map, $refresh = 300)
{
    global $WEATHERMAP_VERSION;
    $filehandle = fopen($htmlfile, 'w');
    fwrite($filehandle, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>');
    if ($map->htmlstylesheet != '') {
        fwrite($filehandle, '<link rel="stylesheet" type="text/css" href="' . $map->htmlstylesheet . '" />');
    }
    fwrite($filehandle, '<meta http-equiv="refresh" content="' . intval($refresh) . '" /><title>' . $map->processString($map->title, $map) . '</title></head><body>');
    if ($map->htmlstyle == "overlib") {
        fwrite($filehandle, "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\n");
        fwrite($filehandle, "<script type=\"text/javascript\" src=\"vendor/overlib.js\"><!-- overLIB (c) Erik Bosrup --></script> \n");
    }
    fwrite($filehandle, $map->makeHTML());
    fwrite($filehandle, '<hr /><span id="byline">Network Map created with <a href="http://www.network-weathermap.com/?vs=' . $WEATHERMAP_VERSION . '">PHP Network Weathermap v' . $WEATHERMAP_VERSION . '</a></span></body></html>');
    fclose($filehandle);
}