Пример #1
0
 public function testHelpers()
 {
     \PHPPE\Core::$core->nocache = true;
     \PHPPE\Core::$core->meta["test"] = "testing";
     \PHPPE\Core::$core->link["apple-touch-icon"] = "testing";
     \PHPPE\View::init([]);
     $dir = dirname(__DIR__);
     \PHPPE\View::setPath($dir);
     \PHPPE\View::assign("dir", $dir);
     \PHPPE\View::css("test.css");
     \PHPPE\View::css("test2.css");
     \PHPPE\View::css(url("css", "test.css"));
     $this->assertNotEmpty(\PHPPE\View::css(), "CSS");
     \PHPPE\View::jslib("test.js", "testjs();");
     \PHPPE\View::jslib("test2.js", "testjs();");
     \PHPPE\View::jslib(url("js", "test.js"), "testjs();");
     $this->assertNotEmpty(\PHPPE\View::jslib(), "JSLib");
     \PHPPE\View::js("some()", "thing();");
     \PHPPE\View::js("some2()", "thing();", true);
     \PHPPE\View::menu("a", "b");
     \PHPPE\View::menu("c", ["d" => "e"]);
     $this->assertNotEmpty(\PHPPE\View::menu(), "Menu");
     $o = \PHPPE\Core::$core->output;
     \PHPPE\Core::$core->output = "ncurses";
     $o = trim(\PHPPE\View::e('D', "message", "module"));
     $this->assertEquals("module-D: message" . chr(27) . "[0m", $o, "error string #1");
     \PHPPE\Core::$core->output = "html";
     $this->assertEquals("<span style='background:#F00000;color:#FEA0A0;padding:3px;'>E-module:&nbsp;[&quot;message&quot;]</span>", trim(\PHPPE\View::e('E', ["message"], "module")), "error string #2");
     \PHPPE\Core::$core->output = $o;
     $this->assertEquals("aaa\n<!include test2>\nbbb\n", \PHPPE\View::get("test1"), "Raw template file");
     \PHPPE\DS::close();
     $ds = new \PHPPE\DS("sqlite::memory:");
     \PHPPE\DS::exec("UPDATE views SET css='[\"a.css\"]' WHERE id='simple'");
     $this->assertNotEmpty(\PHPPE\View::get("simple"), "Raw template db");
     \PHPPE\DS::exec("UPDATE views SET css='' WHERE id='simple'");
 }