Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / SanitizerTest.php
index e665d67..99e8fb7 100644 (file)
@@ -271,4 +271,29 @@ class SanitizerTest extends MediaWikiTestCase {
                $this->setMwGlobals( 'wgFragmentMode', [ 666 => 'html5' ] );
                Sanitizer::escapeIdForLink( 'This should throw' );
        }
+
+       /**
+        * Test escapeIdReferenceList for consistency with escapeIdForAttribute
+        *
+        * @dataProvider provideEscapeIdReferenceList
+        * @covers Sanitizer::escapeIdReferenceList
+        */
+       public function testEscapeIdReferenceList( $referenceList, $id1, $id2 ) {
+               $this->assertEquals(
+                       Sanitizer::escapeIdReferenceList( $referenceList ),
+                       Sanitizer::escapeIdForAttribute( $id1 )
+                       . ' '
+                       . Sanitizer::escapeIdForAttribute( $id2 )
+               );
+       }
+
+       public static function provideEscapeIdReferenceList() {
+               /** [ <reference list>, <individual id 1>, <individual id 2> ] */
+               return [
+                       [ 'foo bar', 'foo', 'bar' ],
+                       [ '#1 #2', '#1', '#2' ],
+                       [ '+1 +2', '+1', '+2' ],
+               ];
+       }
+
 }