diff --git a/tests/lib/template.php b/tests/lib/template.php
index 299eb2b936..eedf688721 100644
--- a/tests/lib/template.php
+++ b/tests/lib/template.php
@@ -28,46 +28,31 @@ class Test_TemplateFunctions extends PHPUnit_Framework_TestCase {
}
public function testPJavaScript() {
- $badString = '
';
- ob_start();
- p($badString);
- $result = ob_get_clean();
- $this->assertEquals('<img onload="alert(1)" />', $result);
+ $this->expectOutputString('<img onload="alert(1)" />');
+ p('
');
}
public function testPJavaScriptWithScriptTags() {
- $badString = "";
- ob_start();
- p($badString);
- $result = ob_get_clean();
- $this->assertEquals('<script>alert('Hacked!');</script>', $result);
+ $this->expectOutputString('<script>alert('Hacked!');</script>');
+ p("");
}
public function testPNormalString() {
- $goodString = 'This is a good string without HTML.';
- ob_start();
- p($goodString);
- $result = ob_get_clean();
- $this->assertEquals('This is a good string without HTML.', $result);
+ $string = 'This is a good string without HTML.';
+ $this->expectOutputString($string);
+ p($string);
}
public function testPrintUnescaped() {
$htmlString = "";
-
- ob_start();
+ $this->expectOutputString($htmlString);
print_unescaped($htmlString);
- $result = ob_get_clean();
-
- $this->assertEquals($htmlString, $result);
}
public function testPrintUnescapedNormalString() {
- $normalString = "This is a good string!";
- ob_start();
- print_unescaped($normalString);
- $result = ob_get_clean();
-
- $this->assertEquals("This is a good string!", $result);
+ $string = 'This is a good string!';
+ $this->expectOutputString($string);
+ print_unescaped($string);
}
// ---------------------------------------------------------------------------