Merge "Use READ_EXCLUSIVE in SpecialConfirmEmail::attemptConfirm"
[lhc/web/wiklou.git] / tests / phpunit / includes / WikiMapTest.php
index 199f638..e87e434 100644 (file)
@@ -239,24 +239,28 @@ class WikiMapTest extends MediaWikiLangTestCase {
                return [
                        [ 'db-prefix', 'db-prefix' ],
                        [ wfWikiID(), wfWikiID() ],
-                       [ new DatabaseDomain( 'db-dash', null, 'prefix' ), 'db-dash-prefix' ]
+                       [ new DatabaseDomain( 'db-dash', null, 'prefix' ), 'db-dash-prefix' ],
+                       [ wfWikiID(), wfWikiID() ],
+                       [ new DatabaseDomain( 'db-dash', null, 'prefix' ), 'db-dash-prefix' ],
+                       [ new DatabaseDomain( 'db', 'mediawiki', 'prefix' ), 'db-prefix' ], // schema ignored
+                       [ new DatabaseDomain( 'db', 'custom', 'prefix' ), 'db-custom-prefix' ],
                ];
        }
 
        /**
         * @dataProvider provideGetWikiIdFromDomain
-        * @covers WikiMap::getWikiIdFromDomain()
+        * @covers WikiMap::getWikiIdFromDbDomain()
         */
        public function testGetWikiIdFromDomain( $domain, $wikiId ) {
-               $this->assertEquals( $wikiId, WikiMap::getWikiIdFromDomain( $domain ) );
+               $this->assertEquals( $wikiId, WikiMap::getWikiIdFromDbDomain( $domain ) );
        }
 
        /**
-        * @covers WikiMap::isCurrentWikiDomain()
-        * @covers WikiMap::getCurrentWikiDomain()
+        * @covers WikiMap::isCurrentWikiDbDomain()
+        * @covers WikiMap::getCurrentWikiDbDomain()
         */
        public function testIsCurrentWikiDomain() {
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( wfWikiID() ) );
+               $this->assertTrue( WikiMap::isCurrentWikiDbDomain( wfWikiID() ) );
 
                $localDomain = DatabaseDomain::newFromId( wfWikiID() );
                $domain1 = new DatabaseDomain(
@@ -264,29 +268,34 @@ class WikiMapTest extends MediaWikiLangTestCase {
                $domain2 = new DatabaseDomain(
                        $localDomain->getDatabase(), null, $localDomain->getTablePrefix() );
 
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( $domain1 ), 'Schema ignored' );
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( $domain2 ), 'Schema ignored' );
+               $this->assertTrue( WikiMap::isCurrentWikiDbDomain( $domain1 ), 'Schema ignored' );
+               $this->assertTrue( WikiMap::isCurrentWikiDbDomain( $domain2 ), 'Schema ignored' );
 
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( WikiMap::getCurrentWikiDomain() ) );
+               $this->assertTrue( WikiMap::isCurrentWikiDbDomain( WikiMap::getCurrentWikiDbDomain() ) );
        }
 
        public function provideIsCurrentWikiId() {
                return [
                        [ 'db', 'db', null, '' ],
-                       [ 'db','db', 'schema', '' ],
+                       [ 'db-schema-','db', 'schema', '' ],
+                       [ 'db','db', 'mediawiki', '' ], // common b/c case
                        [ 'db-prefix', 'db', null, 'prefix' ],
-                       [ 'db-prefix', 'db', 'schema', 'prefix' ],
+                       [ 'db-schema-prefix', 'db', 'schema', 'prefix' ],
+                       [ 'db-prefix', 'db', 'mediawiki', 'prefix' ], // common b/c case
                        // Bad hyphen cases (best effort support)
                        [ 'db-stuff', 'db-stuff', null, '' ],
-                       [ 'db-stuff-prefix', 'db-stuff', null, 'prefix' ]
+                       [ 'db-stuff-prefix', 'db-stuff', null, 'prefix' ],
+                       [ 'db-stuff-schema-', 'db-stuff', 'schema', '' ],
+                       [ 'db-stuff-schema-prefix', 'db-stuff', 'schema', 'prefix' ],
+                       [ 'db-stuff-prefix', 'db-stuff', 'mediawiki', 'prefix' ] // common b/c case
                ];
        }
 
        /**
         * @dataProvider provideIsCurrentWikiId
         * @covers WikiMap::isCurrentWikiId()
-        * @covers WikiMap::getCurrentWikiDomain()
-        * @covers WikiMap::getWikiIdFromDomain()
+        * @covers WikiMap::getCurrentWikiDbDomain()
+        * @covers WikiMap::getWikiIdFromDbDomain()
         */
        public function testIsCurrentWikiId( $wikiId, $db, $schema, $prefix ) {
                $this->setMwGlobals(