Merge "Set context earlier in ImageListPager::__construct"
[lhc/web/wiklou.git] / tests / phpunit / includes / SanitizerTest.php
index 50c1e50..c615c46 100644 (file)
@@ -6,12 +6,6 @@
  */
 class SanitizerTest extends MediaWikiTestCase {
 
-       protected function setUp() {
-               parent::setUp();
-
-               AutoLoader::loadClass( 'Sanitizer' );
-       }
-
        /**
         * @covers Sanitizer::decodeCharReferences
         */
@@ -85,7 +79,7 @@ class SanitizerTest extends MediaWikiTestCase {
         */
        public function testInvalidNumberedEntities() {
                $this->assertEquals(
-                       UTF8_REPLACEMENT,
+                       UtfNormal\Constants::UTF8_REPLACEMENT,
                        Sanitizer::decodeCharReferences( "�" ),
                        'Invalid numbered entity'
                );
@@ -346,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¡b' ),
+                       array( 'foo'bar', "foo'bar" ),
+                       array( '&lt;script&gt;foo&lt;/script&gt;', '<script>foo</script>' ),
+               );
+       }
+
 }