Merge "Add `makeKey` and `makeGlobalKey` to BagOStuff"
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / GlobalTest.php
index 69dcd4c..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,
                );
@@ -583,7 +583,6 @@ 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.
 
@@ -708,81 +707,27 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        public function testWfMemcKey() {
-               // Just assert the exact output so we can catch unintentional changes to key
-               // construction, which would effectively invalidate all existing cache.
-
-               $this->setMwGlobals( array(
-                       'wgCachePrefix' => false,
-                       'wgDBname' => 'example',
-                       'wgDBprefix' => '',
-               ) );
-               $this->assertEquals(
-                       wfMemcKey( 'foo', '123', 'bar' ),
-                       'example:foo:123:bar'
-               );
-
-               $this->setMwGlobals( array(
-                       'wgCachePrefix' => false,
-                       'wgDBname' => 'example',
-                       'wgDBprefix' => 'mw_',
-               ) );
-               $this->assertEquals(
-                       wfMemcKey( 'foo', '123', 'bar' ),
-                       'example-mw_:foo:123:bar'
-               );
-
-               $this->setMwGlobals( array(
-                       'wgCachePrefix' => 'custom',
-                       'wgDBname' => 'example',
-                       'wgDBprefix' => 'mw_',
-               ) );
+               $cache = ObjectCache::getMainClusterInstance();
                $this->assertEquals(
-                       wfMemcKey( 'foo', '123', 'bar' ),
-                       'custom:foo:123:bar'
+                       $cache->makeKey( 'foo', 123, 'bar' ),
+                       wfMemcKey( 'foo', 123, 'bar' )
                );
        }
 
        public function testWfForeignMemcKey() {
-               $this->setMwGlobals( array(
-                       'wgCachePrefix' => false,
-                       'wgDBname' => 'example',
-                       'wgDBprefix' => '',
-               ) );
-               $local = wfMemcKey( 'foo', 'bar' );
-
-               $this->setMwGlobals( array(
-                       'wgDBname' => 'other',
-                       'wgDBprefix' => 'mw_',
-               ) );
+               $cache = ObjectCache::getMainClusterInstance();
+               $keyspace = $this->readAttribute( $cache, 'keyspace' );
                $this->assertEquals(
-                       wfForeignMemcKey( 'example', '', 'foo', 'bar' ),
-                       $local,
-                       'Match output of wfMemcKey from local wiki'
+                       wfForeignMemcKey( $keyspace, '', 'foo', 'bar' ),
+                       $cache->makeKey( 'foo', 'bar' )
                );
        }
 
        public function testWfGlobalCacheKey() {
-               $this->setMwGlobals( array(
-                       'wgCachePrefix' => 'ignored',
-                       'wgDBname' => 'example',
-                       'wgDBprefix' => ''
-               ) );
-               $one = wfGlobalCacheKey( 'some', 'thing' );
-               $this->assertEquals(
-                       $one,
-                       'global:some:thing'
-               );
-
-               $this->setMwGlobals( array(
-                       'wgDBname' => 'other',
-                       'wgDBprefix' => 'mw_'
-               ) );
-               $two = wfGlobalCacheKey( 'some', 'thing' );
-
+               $cache = ObjectCache::getMainClusterInstance();
                $this->assertEquals(
-                       $one,
-                       $two,
-                       'Not fragmented by wiki id'
+                       $cache->makeGlobalKey( 'foo', 123, 'bar' ),
+                       wfGlobalCacheKey( 'foo', 123, 'bar' )
                );
        }