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
This commit is contained in:
parent
72cf7cf448
commit
c7fc73286d
2 changed files with 20 additions and 13 deletions
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group BagOStuff
|
||||
*/
|
||||
class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testEvictionOrder() {
|
||||
$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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue