Merge "Add `makeKey` and `makeGlobalKey` to BagOStuff"
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / GlobalTest.php
index 5c28ece..913c82f 100644 (file)
@@ -306,7 +306,7 @@ class GlobalTest extends MediaWikiTestCase {
 
                $this->setMwGlobals( array(
                        'wgDebugLogFile' => $debugLogFile,
-                       # @todo FIXME: $wgDebugTimestamps should be tested
+                       #  @todo FIXME: $wgDebugTimestamps should be tested
                        'wgDebugTimestamps' => false
                ) );
 
@@ -353,7 +353,7 @@ class GlobalTest extends MediaWikiTestCase {
                        'gzip;q=1.0' => true,
                        'foozip' => false,
                        'foo*zip' => false,
-                       'gzip;q=abcde' => true, //is this REALLY valid?
+                       'gzip;q=abcde' => true, // is this REALLY valid?
                        'gzip;q=12345678.9' => true,
                        ' gzip' => true,
                );
@@ -551,10 +551,10 @@ class GlobalTest extends MediaWikiTestCase {
 
        public static function provideMakeUrlIndexes() {
                return array(
+                       // Testcase for T30627
                        array(
-                               // just a regular :)
-                               'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627',
-                               array( 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' )
+                               'https://example.org/test.cgi?id=12345',
+                               array( 'https://org.example./test.cgi?id=12345' )
                        ),
                        array(
                                // mailtos are handled special
@@ -563,7 +563,7 @@ class GlobalTest extends MediaWikiTestCase {
                                array( 'mailto:org.wikimedia@wiki.' )
                        ),
 
-                       // file URL cases per bug 28627...
+                       // file URL cases per T30627...
                        array(
                                // three slashes: local filesystem path Unix-style
                                'file:///whatever/you/like.txt',
@@ -583,16 +583,15 @@ class GlobalTest extends MediaWikiTestCase {
                        // if you hack it just right are kinda pathological,
                        // and unreliable cross-platform or on IE which means they're
                        // unlikely to appear on intranets.
-                       //
                        // Those will survive the algorithm but with results that
                        // are less consistent.
 
-                       // protocol-relative URL cases per bug 29854...
+                       // protocol-relative URL cases per T31854...
                        array(
-                               '//bugzilla.wikimedia.org/show_bug.cgi?id=28627',
+                               '//example.org/test.cgi?id=12345',
                                array(
-                                       'http://org.wikimedia.bugzilla./show_bug.cgi?id=28627',
-                                       'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
+                                       'http://org.example./test.cgi?id=12345',
+                                       'https://org.example./test.cgi?id=12345'
                                )
                        ),
                );
@@ -687,6 +686,51 @@ class GlobalTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $actual, $description );
        }
 
+       public function wfWikiID() {
+               $this->setMwGlobals( array(
+                       'wgDBname' => 'example',
+                       'wgDBprefix' => '',
+               ) );
+               $this->assertEquals(
+                       wfWikiID(),
+                       'example'
+               );
+
+               $this->setMwGlobals( array(
+                       'wgDBname' => 'example',
+                       'wgDBprefix' => 'mw_',
+               ) );
+               $this->assertEquals(
+                       wfWikiID(),
+                       'example-mw_'
+               );
+       }
+
+       public function testWfMemcKey() {
+               $cache = ObjectCache::getMainClusterInstance();
+               $this->assertEquals(
+                       $cache->makeKey( 'foo', 123, 'bar' ),
+                       wfMemcKey( 'foo', 123, 'bar' )
+               );
+       }
+
+       public function testWfForeignMemcKey() {
+               $cache = ObjectCache::getMainClusterInstance();
+               $keyspace = $this->readAttribute( $cache, 'keyspace' );
+               $this->assertEquals(
+                       wfForeignMemcKey( $keyspace, '', 'foo', 'bar' ),
+                       $cache->makeKey( 'foo', 'bar' )
+               );
+       }
+
+       public function testWfGlobalCacheKey() {
+               $cache = ObjectCache::getMainClusterInstance();
+               $this->assertEquals(
+                       $cache->makeGlobalKey( 'foo', 123, 'bar' ),
+                       wfGlobalCacheKey( 'foo', 123, 'bar' )
+               );
+       }
+
        public static function provideWfShellWikiCmdList() {
                global $wgPhpCli;