build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / objectcache / WANObjectCacheTest.php
index 728e671..3d405fa 100644 (file)
@@ -176,7 +176,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase  {
                $priorValue = null;
                $priorAsOf = null;
                $wasSet = 0;
-               $func = function( $old, &$ttl, &$opts, $asOf )
+               $func = function ( $old, &$ttl, &$opts, $asOf )
                use ( &$wasSet, &$priorValue, &$priorAsOf, $value )
                {
                        ++$wasSet;
@@ -583,7 +583,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase  {
                $value = wfRandomString();
 
                $calls = 0;
-               $func = function() use ( &$calls, $value, $cache, $key ) {
+               $func = function () use ( &$calls, $value, $cache, $key ) {
                        ++$calls;
                        // Immediately kill any mutex rather than waiting a second
                        $cache->delete( $cache::MUTEX_KEY_PREFIX . $key );
@@ -625,7 +625,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase  {
                $value = wfRandomString();
 
                $calls = 0;
-               $func = function( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value, $cache, $key ) {
+               $func = function ( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value, $cache, $key ) {
                        ++$calls;
                        $setOpts['since'] = microtime( true ) - 10;
                        // Immediately kill any mutex rather than waiting a second
@@ -659,7 +659,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase  {
                $busyValue = wfRandomString();
 
                $calls = 0;
-               $func = function() use ( &$calls, $value, $cache, $key ) {
+               $func = function () use ( &$calls, $value, $cache, $key ) {
                        ++$calls;
                        // Immediately kill any mutex rather than waiting a second
                        $cache->delete( $cache::MUTEX_KEY_PREFIX . $key );
@@ -921,7 +921,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase  {
                $value = wfRandomString();
 
                $wasSet = 0;
-               $func = function( $old, &$ttl ) use ( &$wasSet, $value ) {
+               $func = function ( $old, &$ttl ) use ( &$wasSet, $value ) {
                        ++$wasSet;
                        return $value;
                };
@@ -1191,4 +1191,40 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase  {
                        [ null, 86400, 800, .2, 800 ]
                ];
        }
+
+       /**
+        * @covers WANObjectCache::makeKey
+        */
+       public function testMakeKey() {
+               $backend = $this->getMockBuilder( HashBagOStuff::class )
+                       ->setMethods( [ 'makeKey' ] )->getMock();
+               $backend->expects( $this->once() )->method( 'makeKey' )
+                       ->willReturn( 'special' );
+
+               $wanCache = new WANObjectCache( [
+                       'cache' => $backend,
+                       'pool' => 'testcache-hash',
+                       'relayer' => new EventRelayerNull( [] )
+               ] );
+
+               $this->assertSame( 'special', $wanCache->makeKey( 'a', 'b' ) );
+       }
+
+       /**
+        * @covers WANObjectCache::makeGlobalKey
+        */
+       public function testMakeGlobalKey() {
+               $backend = $this->getMockBuilder( HashBagOStuff::class )
+                       ->setMethods( [ 'makeGlobalKey' ] )->getMock();
+               $backend->expects( $this->once() )->method( 'makeGlobalKey' )
+                       ->willReturn( 'special' );
+
+               $wanCache = new WANObjectCache( [
+                       'cache' => $backend,
+                       'pool' => 'testcache-hash',
+                       'relayer' => new EventRelayerNull( [] )
+               ] );
+
+               $this->assertSame( 'special', $wanCache->makeGlobalKey( 'a', 'b' ) );
+       }
 }