From a31c230f229c9e28438c221a6e585e7b8bf1cda6 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 29 Oct 2012 21:22:25 +0100 Subject: [PATCH] added tests for p and print_unescaped --- tests/lib/template.php | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/lib/template.php diff --git a/tests/lib/template.php b/tests/lib/template.php new file mode 100644 index 0000000000..27feec13d0 --- /dev/null +++ b/tests/lib/template.php @@ -0,0 +1,67 @@ +. +* +*/ + +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(); + + $this->assertEqual($result, "<script>alert('xss');</script>"); + + ob_end_clean(); + $normalString = "This is a good string!"; + ob_start(); + p($normalString); + $result = ob_get_clean(); + + $this->assertEqual($result, "This is a good string!"); + + } + + + public function testPrintUnescaped(){ + $htmlString = ""; + + ob_start(); + print_unescaped($htmlString); + $result = ob_get_clean(); + + $this->assertEqual($result, $htmlString); + + ob_end_clean(); + $normalString = "This is a good string!"; + ob_start(); + p($normalString); + $result = ob_get_clean(); + + $this->assertEqual($result, "This is a good string!"); + + } + + +} \ No newline at end of file