From: jenkins-bot Date: Thu, 15 Jun 2017 16:22:37 +0000 (+0000) Subject: Merge "Add | to error message about invalid change tag characters" X-Git-Tag: 1.31.0-rc.0~2969 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=a66d17af3cdbfaf1a12096ba7038c7cb744eeb68;hp=1e5704d488530edb26451329a05440f3a89c08ef;p=lhc%2Fweb%2Fwiklou.git Merge "Add | to error message about invalid change tag characters" --- diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php index 9dcfa7c55e..687c67c356 100644 --- a/includes/libs/objectcache/MultiWriteBagOStuff.php +++ b/includes/libs/objectcache/MultiWriteBagOStuff.php @@ -226,4 +226,12 @@ class MultiWriteBagOStuff extends BagOStuff { return $ret; } + + public function makeKey() { + return call_user_func_array( [ $this->caches[0], __FUNCTION__ ], func_get_args() ); + } + + public function makeGlobalKey() { + return call_user_func_array( [ $this->caches[0], __FUNCTION__ ], func_get_args() ); + } } diff --git a/tests/phpunit/includes/libs/objectcache/MultiWriteBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/MultiWriteBagOStuffTest.php index 38d63e341c..775709f241 100644 --- a/tests/phpunit/includes/libs/objectcache/MultiWriteBagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/MultiWriteBagOStuffTest.php @@ -98,4 +98,39 @@ class MultiWriteBagOStuffTest extends MediaWikiTestCase { // Set in tier 2 $this->assertEquals( $value, $this->cache2->get( $key ), 'Written to tier 2' ); } + + /** + * @covers MultiWriteBagOStuff::makeKey + */ + public function testMakeKey() { + $cache1 = $this->getMockBuilder( HashBagOStuff::class ) + ->setMethods( [ 'makeKey' ] )->getMock(); + $cache1->expects( $this->once() )->method( 'makeKey' ) + ->willReturn( 'special' ); + + $cache2 = $this->getMockBuilder( HashBagOStuff::class ) + ->setMethods( [ 'makeKey' ] )->getMock(); + $cache2->expects( $this->never() )->method( 'makeKey' ); + + $cache = new MultiWriteBagOStuff( [ 'caches' => [ $cache1, $cache2 ] ] ); + $this->assertSame( 'special', $cache->makeKey( 'a', 'b' ) ); + } + + /** + * @covers MultiWriteBagOStuff::makeGlobalKey + */ + public function testMakeGlobalKey() { + $cache1 = $this->getMockBuilder( HashBagOStuff::class ) + ->setMethods( [ 'makeGlobalKey' ] )->getMock(); + $cache1->expects( $this->once() )->method( 'makeGlobalKey' ) + ->willReturn( 'special' ); + + $cache2 = $this->getMockBuilder( HashBagOStuff::class ) + ->setMethods( [ 'makeGlobalKey' ] )->getMock(); + $cache2->expects( $this->never() )->method( 'makeGlobalKey' ); + + $cache = new MultiWriteBagOStuff( [ 'caches' => [ $cache1, $cache2 ] ] ); + + $this->assertSame( 'special', $cache->makeGlobalKey( 'a', 'b' ) ); + } } diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index 728e6717d2..2b0436614e 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -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' ) ); + } } diff --git a/tests/phpunit/mocks/filebackend/MockFSFile.php b/tests/phpunit/mocks/filebackend/MockFSFile.php index 8ee45a87cf..047c03ad1f 100644 --- a/tests/phpunit/mocks/filebackend/MockFSFile.php +++ b/tests/phpunit/mocks/filebackend/MockFSFile.php @@ -22,8 +22,8 @@ */ /** - * Class representing an in memory fake file. - * This is intended for unit testing / developement when you do not want + * Class representing an in-memory fake file. + * This is intended for unit testing / development when you do not want * to hit the filesystem. * * It reimplements abstract methods with some hardcoded values. Might