Enable email settings for ApiBlockTest::testBlockWithEmailBlock
[lhc/web/wiklou.git] / tests / phpunit / includes / WikiMapTest.php
index 1fb8aff..1608b9c 100644 (file)
@@ -237,41 +237,44 @@ class WikiMapTest extends MediaWikiLangTestCase {
 
        public function provideGetWikiIdFromDomain() {
                return [
-                       [ 'db-prefix', 'db-prefix' ],
+                       [ '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' ],
+                       [ 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->setMwGlobals( 'wgDBmwschema', 'mediawiki' );
 
-               $localDomain = DatabaseDomain::newFromId( wfWikiID() );
+               $localDomain = WikiMap::getCurrentWikiDbDomain()->getId();
+               $this->assertTrue( WikiMap::isCurrentWikiDbDomain( $localDomain ) );
+
+               $localDomain = DatabaseDomain::newFromId( $localDomain );
                $domain1 = new DatabaseDomain(
                        $localDomain->getDatabase(), 'someschema', $localDomain->getTablePrefix() );
                $domain2 = new DatabaseDomain(
                        $localDomain->getDatabase(), null, $localDomain->getTablePrefix() );
 
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( $domain1 ), 'Schema ignored' );
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( $domain2 ), 'Schema ignored' );
+               $this->assertFalse( WikiMap::isCurrentWikiDbDomain( $domain1 ), 'Schema not ignored' );
+               $this->assertFalse( WikiMap::isCurrentWikiDbDomain( $domain2 ), 'Null schema not ignored' );
 
-               $this->assertTrue( WikiMap::isCurrentWikiDomain( WikiMap::getCurrentWikiDomain() ) );
+               $this->assertTrue( WikiMap::isCurrentWikiDbDomain( WikiMap::getCurrentWikiDbDomain() ) );
        }
 
        public function provideIsCurrentWikiId() {
@@ -279,23 +282,23 @@ class WikiMapTest extends MediaWikiLangTestCase {
                        [ 'db', 'db', null, '' ],
                        [ 'db-schema-','db', 'schema', '' ],
                        [ 'db','db', 'mediawiki', '' ], // common b/c case
-                       [ 'db-prefix', 'db', null, 'prefix' ],
-                       [ 'db-schema-prefix', 'db', 'schema', 'prefix' ],
-                       [ 'db-prefix', 'db', 'mediawiki', 'prefix' ], // common b/c case
+                       [ 'db-prefix_', 'db', null, '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
+                       [ '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(