Merge "code-quality: Special:PrefixIndex is transcludable"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleTest.php
index 58f0146..078dfef 100644 (file)
@@ -40,6 +40,21 @@ class TitleTest extends MediaWikiTestCase {
         * @todo This method should be split into 2 separate tests each with a provider
         */
        public function testSecureAndSplit() {
+               $this->setMwGlobals( array(
+                       'wgLocalInterwiki' => 'localtestiw',
+                       'wgHooks' => array(
+                               'InterwikiLoadPrefix' => array(
+                                       function ( $prefix, &$data ) {
+                                               if ( $prefix === 'localtestiw' ) {
+                                                       $data = array( 'iw_url' => 'localtestiw' );
+                                               } elseif ( $prefix === 'remotetestiw' ) {
+                                                       $data = array( 'iw_url' => 'remotetestiw' );
+                                               }
+                                               return false;
+                                       }
+                               )
+                       )
+               ));
                // Valid
                foreach ( array(
                        'Sandbox',
@@ -58,7 +73,17 @@ class TitleTest extends MediaWikiTestCase {
                        'A~~',
                        // Length is 256 total, but only title part matters
                        'Category:' . str_repeat( 'x', 248 ),
-                       str_repeat( 'x', 252 )
+                       str_repeat( 'x', 252 ),
+                       // interwiki prefix
+                       'localtestiw: #anchor',
+                       'localtestiw:foo',
+                       'localtestiw: foo # anchor',
+                       'localtestiw: Talk: Sandbox # anchor',
+                       'remotetestiw:',
+                       'remotetestiw: Talk: # anchor',
+                       'remotetestiw: #bar',
+                       'remotetestiw: Talk:',
+                       'remotetestiw: Talk: Foo'
                ) as $text ) {
                        $this->assertInstanceOf( 'Title', Title::newFromText( $text ), "Valid: $text" );
                }
@@ -104,10 +129,13 @@ class TitleTest extends MediaWikiTestCase {
                        'A ~~~~~ Timestamp',
                        str_repeat( 'x', 256 ),
                        // Namespace prefix without actual title
-                       // ':', // bug 54044
                        'Talk:',
                        'Category: ',
-                       'Category: #bar'
+                       'Category: #bar',
+                       // interwiki prefix
+                       'localtestiw:',
+                       'localtestiw: Talk: # anchor',
+                       'localtestiw: Talk:'
                ) as $text ) {
                        $this->assertNull( Title::newFromText( $text ), "Invalid: $text" );
                }