X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flibs%2Fobjectcache%2FWANObjectCacheTest.php;h=77198f9d18f0969e1fa971341f7c3ec3c054fa1a;hb=77e3624caba072521fbc1826af2d47f9b29f4032;hp=e534f92513a29f942ec417a685ee3d73a67ec83e;hpb=78418f5728259c024ac3b2016e1edd0ab794c9c0;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index e534f92513..77198f9d18 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -16,7 +16,10 @@ use Wikimedia\TestingAccessWrapper; * @covers WANObjectCache::getInterimValue * @covers WANObjectCache::setInterimValue */ -class WANObjectCacheTest extends PHPUnit_Framework_TestCase { +class WANObjectCacheTest extends PHPUnit\Framework\TestCase { + + use MediaWikiCoversValidator; + /** @var TimeAdjustableWANObjectCache */ private $cache; /** @var BagOStuff */ @@ -618,7 +621,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $this->assertEquals( count( $ids ), $calls, "Values cached" ); // Mock the BagOStuff to assure only one getMulti() call given process caching - $localBag = $this->getMockBuilder( 'HashBagOStuff' ) + $localBag = $this->getMockBuilder( HashBagOStuff::class ) ->setMethods( [ 'getMulti' ] )->getMock(); $localBag->expects( $this->exactly( 1 ) )->method( 'getMulti' )->willReturn( [ WANObjectCache::VALUE_KEY_PREFIX . 'k1' => 'val-id1', @@ -1471,14 +1474,17 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { } public function testMcRouterSupport() { - $localBag = $this->getMockBuilder( 'EmptyBagOStuff' ) + $localBag = $this->getMockBuilder( EmptyBagOStuff::class ) ->setMethods( [ 'set', 'delete' ] )->getMock(); $localBag->expects( $this->never() )->method( 'set' ); $localBag->expects( $this->never() )->method( 'delete' ); $wanCache = new WANObjectCache( [ 'cache' => $localBag, 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) + 'relayer' => new EventRelayerNull( [] ), + 'mcrouterAware' => true, + 'region' => 'pmtpa', + 'cluster' => 'mw-wan' ] ); $valFunc = function () { return 1; @@ -1495,6 +1501,60 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $wanCache->reap( 'zzz', time() - 300 ); } + public function testMcRouterSupportBroadcastDelete() { + $localBag = $this->getMockBuilder( EmptyBagOStuff::class ) + ->setMethods( [ 'set' ] )->getMock(); + $wanCache = new WANObjectCache( [ + 'cache' => $localBag, + 'pool' => 'testcache-hash', + 'relayer' => new EventRelayerNull( [] ), + 'mcrouterAware' => true, + 'region' => 'pmtpa', + 'cluster' => 'mw-wan' + ] ); + + $localBag->expects( $this->once() )->method( 'set' ) + ->with( "/*/mw-wan/" . $wanCache::VALUE_KEY_PREFIX . "test" ); + + $wanCache->delete( 'test' ); + } + + public function testMcRouterSupportBroadcastTouchCK() { + $localBag = $this->getMockBuilder( EmptyBagOStuff::class ) + ->setMethods( [ 'set' ] )->getMock(); + $wanCache = new WANObjectCache( [ + 'cache' => $localBag, + 'pool' => 'testcache-hash', + 'relayer' => new EventRelayerNull( [] ), + 'mcrouterAware' => true, + 'region' => 'pmtpa', + 'cluster' => 'mw-wan' + ] ); + + $localBag->expects( $this->once() )->method( 'set' ) + ->with( "/*/mw-wan/" . $wanCache::TIME_KEY_PREFIX . "test" ); + + $wanCache->touchCheckKey( 'test' ); + } + + public function testMcRouterSupportBroadcastResetCK() { + $localBag = $this->getMockBuilder( EmptyBagOStuff::class ) + ->setMethods( [ 'delete' ] )->getMock(); + $wanCache = new WANObjectCache( [ + 'cache' => $localBag, + 'pool' => 'testcache-hash', + 'relayer' => new EventRelayerNull( [] ), + 'mcrouterAware' => true, + 'region' => 'pmtpa', + 'cluster' => 'mw-wan' + ] ); + + $localBag->expects( $this->once() )->method( 'delete' ) + ->with( "/*/mw-wan/" . $wanCache::TIME_KEY_PREFIX . "test" ); + + $wanCache->resetCheckKey( 'test' ); + } + /** * @dataProvider provideAdaptiveTTL * @covers WANObjectCache::adaptiveTTL()