Merge "Set relevant title on Special:RecentChangesLinked"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleTest.php
index 6871582..53e8dc2 100644 (file)
@@ -20,6 +20,19 @@ class TitleTest extends MediaWikiTestCase {
                ) );
        }
 
+       public function addDBData() {
+               $this->db->replace( 'interwiki', 'iw_prefix',
+                       array(
+                               'iw_prefix' => 'externalwiki',
+                               'iw_url' => '//example.com/$1',
+                               'iw_api' => '//example.com/api.php',
+                               'iw_wikiid' => '',
+                               'iw_local' => 0,
+                               'iw_trans' => 0,
+                       )
+               );
+       }
+
        /**
         * @covers Title::legalChars
         */
@@ -46,7 +59,7 @@ class TitleTest extends MediaWikiTestCase {
         * See also mediawiki.Title.test.js
         * @covers Title::secureAndSplit
         * @todo This method should be split into 2 separate tests each with a provider
-        * @note: This mainly tests MediaWikiTitleCodec::parseTitle().
+        * @note This mainly tests MediaWikiTitleCodec::parseTitle().
         */
        public function testSecureAndSplit() {
                $this->setMwGlobals( array(
@@ -606,4 +619,28 @@ class TitleTest extends MediaWikiTestCase {
                $title = Title::newFromText( $full );
                $this->assertEquals( $fragment, $title->getFragment() );
        }
+
+       /**
+        * @covers Title::isAlwaysKnown
+        * @dataProvider provideIsAlwaysKnown
+        * @param string $page
+        * @param bool $isKnown
+        */
+       public function testIsAlwaysKnown( $page, $isKnown ) {
+               $title = Title::newFromText( $page );
+               $this->assertEquals( $isKnown, $title->isAlwaysKnown() );
+       }
+
+       public function provideIsAlwaysKnown() {
+               return array(
+                       array( 'Some nonexistent page', false ),
+                       array( 'UTPage', false ),
+                       array( '#test', true ),
+                       array( 'Special:BlankPage', true ),
+                       array( 'Special:SomeNonexistentSpecialPage', false ),
+                       array( 'MediaWiki:Parentheses', true ),
+                       array( 'MediaWiki:Some nonexistent message', false ),
+                       array( 'externalwiki:Interwiki link', true ),
+               );
+       }
 }