X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flibs%2Fobjectcache%2FWANObjectCacheTest.php;h=aa46c966ad4622f31d7429d651bd0f904002eca0;hb=43ff2a83b53e82193174fa78d9f300be6f5c79c7;hp=f43a3f3fe915f9f7a8edaba8f8b6b90900b168f8;hpb=1d95c68977ef49738eb0fc9c3701afe06467fbeb;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index f43a3f3fe9..aa46c966ad 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -1,6 +1,6 @@ getCliArg( 'use-wanobjectcache' ) ) { - $name = $this->getCliArg( 'use-wanobjectcache' ); - - $this->cache = ObjectCache::getWANInstance( $name ); - } else { - $this->cache = new WANObjectCache( [ - 'cache' => new HashBagOStuff(), - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) - ] ); - } + $this->cache = new WANObjectCache( [ + 'cache' => new HashBagOStuff(), + 'pool' => 'testcache-hash', + 'relayer' => new EventRelayerNull( [] ) + ] ); $wanCache = TestingAccessWrapper::newFromObject( $this->cache ); /** @noinspection PhpUndefinedFieldInspection */ @@ -147,6 +141,19 @@ class WANObjectCacheTest extends MediaWikiTestCase { $key, 100, $callback, [ 'pcTTL' => 5, 'pcGroup' => $groups[$i] ] ); } $this->assertEquals( 9, $hit, "Values evicted" ); + + $key = reset( $keys ); + // Get into cache + $this->cache->getWithSetCallback( $key, 100, $callback, [ 'pcTTL' => 5 ] ); + $this->cache->getWithSetCallback( $key, 100, $callback, [ 'pcTTL' => 5 ] ); + $this->assertEquals( 10, $hit, "Value cached" ); + $outerCallback = function () use ( &$callback, $key ) { + $v = $this->cache->getWithSetCallback( $key, 100, $callback, [ 'pcTTL' => 5 ] ); + + return 43 + $v; + }; + $this->cache->getWithSetCallback( $key, 100, $outerCallback ); + $this->assertEquals( 11, $hit, "Nested callback value process cache skipped" ); } /** @@ -206,7 +213,7 @@ class WANObjectCacheTest extends MediaWikiTestCase { $this->assertEquals( $value, $v, "Value returned" ); $this->assertEquals( 1, $wasSet, "Value regenerated due to check keys" ); $this->assertEquals( $value, $priorValue, "Has prior value" ); - $this->assertType( 'float', $priorAsOf, "Has prior value" ); + $this->assertInternalType( 'float', $priorAsOf, "Has prior value" ); $t1 = $cache->getCheckKeyTime( $cKey1 ); $this->assertGreaterThanOrEqual( $priorTime, $t1, 'Check keys generated on miss' ); $t2 = $cache->getCheckKeyTime( $cKey2 ); @@ -252,7 +259,7 @@ class WANObjectCacheTest extends MediaWikiTestCase { /** * @dataProvider getMultiWithSetCallback_provider - * @covers WANObjectCache::geMultitWithSetCallback() + * @covers WANObjectCache::getMultiWithSetCallback() * @covers WANObjectCache::makeMultiKeys() * @param array $extOpts * @param bool $versioned @@ -316,7 +323,7 @@ class WANObjectCacheTest extends MediaWikiTestCase { $this->assertEquals( $value, $v[$keyB], "Value returned" ); $this->assertEquals( 1, $wasSet, "Value regenerated due to check keys" ); $this->assertEquals( $value, $priorValue, "Has prior value" ); - $this->assertType( 'float', $priorAsOf, "Has prior value" ); + $this->assertInternalType( 'float', $priorAsOf, "Has prior value" ); $t1 = $cache->getCheckKeyTime( $cKey1 ); $this->assertGreaterThanOrEqual( $priorTime, $t1, 'Check keys generated on miss' ); $t2 = $cache->getCheckKeyTime( $cKey2 );