From: Timo Tijhof Date: Tue, 3 Nov 2015 05:28:18 +0000 (+0000) Subject: objectcache: Move unit tests for HashBagOStuff to its own suite X-Git-Tag: 1.31.0-rc.0~9131^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=c7fc73286d39a2ca848ee00a588fbccd23a850d3;p=lhc%2Fweb%2Fwiklou.git objectcache: Move unit tests for HashBagOStuff to its own suite Follows-up 7cddc22. Also use PHPUnit_Framework_TestCase as parent instead of MediaWikiTestCase in preparation for library extraction. Change-Id: I0e68e56ecf8376b52a59c33ba6dd18b671bdcfc9 --- diff --git a/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php index 55f71cc4f0..94b74cb651 100644 --- a/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php +++ b/tests/phpunit/includes/libs/objectcache/BagOStuffTest.php @@ -240,17 +240,4 @@ class BagOStuffTest extends MediaWikiTestCase { $this->assertType( 'ScopedCallback', $value1, 'First reentrant call returned lock' ); $this->assertType( 'ScopedCallback', $value1, 'Second reentrant call returned lock' ); } - - public function testHashBagEviction() { - $cache = new HashBagOStuff( array( 'maxKeys' => 10 ) ); - for ( $i=0; $i<10; ++$i ) { - $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); - } - for ( $i=10; $i<20; ++$i ) { - $cache->set( "key$i", 1 ); - $this->assertEquals( 1, $cache->get( "key$i" ) ); - $this->assertEquals( false, $cache->get( "key" . $i - 10 ) ); - } - } } diff --git a/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php new file mode 100644 index 0000000000..5344e2d51c --- /dev/null +++ b/tests/phpunit/includes/libs/objectcache/HashBagOStuffTest.php @@ -0,0 +1,20 @@ + 10 ) ); + for ( $i = 0; $i < 10; $i++ ) { + $cache->set( "key$i", 1 ); + $this->assertEquals( 1, $cache->get( "key$i" ) ); + } + for ( $i = 10; $i < 20; $i++ ) { + $cache->set( "key$i", 1 ); + $this->assertEquals( 1, $cache->get( "key$i" ) ); + $this->assertEquals( false, $cache->get( "key" . $i - 10 ) ); + } + } +}