]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - tests/phpunit/includes/libs/HtmlArmorTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / phpunit / includes / libs / HtmlArmorTest.php
diff --git a/tests/phpunit/includes/libs/HtmlArmorTest.php b/tests/phpunit/includes/libs/HtmlArmorTest.php
new file mode 100644 (file)
index 0000000..5f176e0
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * @covers HtmlArmor
+ */
+class HtmlArmorTest extends PHPUnit_Framework_TestCase {
+
+       public static function provideHtmlArmor() {
+               return [
+                       [
+                               'foobar',
+                               'foobar',
+                       ],
+                       [
+                               '<script>alert("evil!");</script>',
+                               '&lt;script&gt;alert(&quot;evil!&quot;);&lt;/script&gt;',
+                       ],
+                       [
+                               new HtmlArmor( '<script>alert("evil!");</script>' ),
+                               '<script>alert("evil!");</script>',
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideHtmlArmor
+        */
+       public function testHtmlArmor( $input, $expected ) {
+               $this->assertEquals(
+                       $expected,
+                       HtmlArmor::getHtml( $input )
+               );
+       }
+}