Merge "Give TestCase::checkHasDiff3 a better name"
[lhc/web/wiklou.git] / tests / phpunit / includes / SanitizerTest.php
index c615c46..ca1ec50 100644 (file)
@@ -6,6 +6,11 @@
  */
 class SanitizerTest extends MediaWikiTestCase {
 
+       protected function tearDown() {
+               MWTidy::destroySingleton();
+               parent::tearDown();
+       }
+
        /**
         * @covers Sanitizer::decodeCharReferences
         */
@@ -93,9 +98,7 @@ class SanitizerTest extends MediaWikiTestCase {
         * @param bool $escaped Whether sanitizer let the tag in or escape it (ie: '<video>')
         */
        public function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) {
-               $this->setMwGlobals( array(
-                       'wgUseTidy' => false
-               ) );
+               MWTidy::setInstance( false );
 
                if ( $escaped ) {
                        $this->assertEquals( "<$tag>",
@@ -157,7 +160,7 @@ class SanitizerTest extends MediaWikiTestCase {
         * @covers Sanitizer::removeHTMLtags
         */
        public function testRemoveHTMLtags( $input, $output, $msg = null ) {
-               $GLOBALS['wgUseTidy'] = false;
+               MWTidy::setInstance( false );
                $this->assertEquals( $output, Sanitizer::removeHTMLtags( $input ), $msg );
        }
 
@@ -314,33 +317,6 @@ class SanitizerTest extends MediaWikiTestCase {
                );
        }
 
-       /**
-        * Test for support or lack of support for specific attributes in the attribute whitelist.
-        */
-       public static function provideAttributeSupport() {
-               /** array( <attributes>, <expected>, <message> ) */
-               return array(
-                       array(
-                               'div',
-                               ' role="presentation"',
-                               ' role="presentation"',
-                               'Support for WAI-ARIA\'s role="presentation".'
-                       ),
-                       array( 'div', ' role="main"', '', "Other WAI-ARIA roles are currently not supported." ),
-               );
-       }
-
-       /**
-        * @dataProvider provideAttributeSupport
-        * @covers Sanitizer::fixTagAttributes
-        */
-       public function testAttributeSupport( $tag, $attributes, $expected, $message ) {
-               $this->assertEquals( $expected,
-                       Sanitizer::fixTagAttributes( $attributes, $tag ),
-                       $message
-               );
-       }
-
        /**
         * @dataProvider provideEscapeHtmlAllowEntities
         * @covers Sanitizer::escapeHtmlAllowEntities
@@ -361,4 +337,27 @@ class SanitizerTest extends MediaWikiTestCase {
                );
        }
 
+       /**
+        * Test escapeIdReferenceList for consistency with escapeId
+        *
+        * @dataProvider provideEscapeIdReferenceList
+        * @covers Sanitizer::escapeIdReferenceList
+        */
+       public function testEscapeIdReferenceList( $referenceList, $id1, $id2 ) {
+               $this->assertEquals(
+                       Sanitizer::escapeIdReferenceList( $referenceList, 'noninitial' ),
+                       Sanitizer::escapeId( $id1, 'noninitial' )
+                               . ' '
+                               . Sanitizer::escapeId( $id2, 'noninitial' )
+               );
+       }
+
+       public static function provideEscapeIdReferenceList() {
+               /** array( <reference list>, <individual id 1>, <individual id 2> ) */
+               return array(
+                       array( 'foo bar', 'foo', 'bar' ),
+                       array( '#1 #2', '#1', '#2' ),
+                       array( '+1 +2', '+1', '+2' ),
+               );
+       }
 }