$priorValue = null;
$priorAsOf = null;
$wasSet = 0;
- $func = function( $old, &$ttl, &$opts, $asOf )
+ $func = function ( $old, &$ttl, &$opts, $asOf )
use ( &$wasSet, &$priorValue, &$priorAsOf, $value )
{
++$wasSet;
$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 );
$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
$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 );
$value = wfRandomString();
$wasSet = 0;
- $func = function( $old, &$ttl ) use ( &$wasSet, $value ) {
+ $func = function ( $old, &$ttl ) use ( &$wasSet, $value ) {
++$wasSet;
return $value;
};
[ 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' ) );
+ }
}