diff --git a/tests/lib/template.php b/tests/lib/template.php
new file mode 100644
index 0000000000..dadfdba5e0
--- /dev/null
+++ b/tests/lib/template.php
@@ -0,0 +1,71 @@
+.
+*
+*/
+
+require_once("lib/template.php");
+
+class Test_TemplateFunctions extends UnitTestCase {
+
+ public function testP(){
+ // FIXME: do we need more testcases?
+ $htmlString = "";
+ ob_start();
+ p($htmlString);
+ $result = ob_get_clean();
+ ob_end_clean();
+
+ $this->assertEqual("<script>alert('xss');</script>", $result);
+ }
+
+ public function testPNormalString(){
+ $normalString = "This is a good string!";
+ ob_start();
+ p($normalString);
+ $result = ob_get_clean();
+ ob_end_clean();
+
+ $this->assertEqual("This is a good string!", $result);
+ }
+
+
+ public function testPrintUnescaped(){
+ $htmlString = "";
+
+ ob_start();
+ print_unescaped($htmlString);
+ $result = ob_get_clean();
+ ob_end_clean();
+
+ $this->assertEqual($htmlString, $result);
+ }
+
+ public function testPrintUnescapedNormalString(){
+ $normalString = "This is a good string!";
+ ob_start();
+ print_unescaped($normalString);
+ $result = ob_get_clean();
+ ob_end_clean();
+
+ $this->assertEqual("This is a good string!", $result);
+ }
+
+
+}