Add tests for Sanitizer::escapeHtmlAllowEntities
authorMarius Hoch <hoo@online.de>
Wed, 14 Jan 2015 23:22:06 +0000 (00:22 +0100)
committerMarius Hoch <hoo@online.de>
Wed, 14 Jan 2015 23:25:24 +0000 (00:25 +0100)
Change-Id: I84a1328559d57a424aa77a6d89f837615feffc13

tests/phpunit/includes/SanitizerTest.php

index f960f48..36ad3cc 100644 (file)
@@ -340,4 +340,25 @@ class SanitizerTest extends MediaWikiTestCase {
                        $message
                );
        }
+
+       /**
+        * @dataProvider provideEscapeHtmlAllowEntities
+        * @covers Sanitizer::escapeHtmlAllowEntities
+        */
+       public function testEscapeHtmlAllowEntities( $expected, $html ) {
+               $this->assertEquals(
+                       $expected,
+                       Sanitizer::escapeHtmlAllowEntities( $html )
+               );
+       }
+
+       public static function provideEscapeHtmlAllowEntities() {
+               return array(
+                       array( 'foo', 'foo' ),
+                       array( 'a¡b', 'a&#161;b' ),
+                       array( 'foo&#039;bar', "foo'bar" ),
+                       array( '&lt;script&gt;foo&lt;/script&gt;', '<script>foo</script>' ),
+               );
+       }
+
 }