*/
class CachedBagOStuffTest extends PHPUnit_Framework_TestCase {
+ /**
+ * @covers CachedBagOStuff::__construct
+ * @covers CachedBagOStuff::doGet
+ */
public function testGetFromBackend() {
$backend = new HashBagOStuff;
$cache = new CachedBagOStuff( $backend );
$this->assertEquals( 'bar', $cache->get( 'foo' ), 'cached' );
}
+ /**
+ * @covers CachedBagOStuff::set
+ * @covers CachedBagOStuff::delete
+ */
public function testSetAndDelete() {
$backend = new HashBagOStuff;
$cache = new CachedBagOStuff( $backend );
}
}
+ /**
+ * @covers CachedBagOStuff::set
+ * @covers CachedBagOStuff::delete
+ */
public function testWriteCacheOnly() {
$backend = new HashBagOStuff;
$cache = new CachedBagOStuff( $backend );
$this->assertEquals( 'old', $cache->get( 'foo' ) ); // Reloaded from backend
}
+ /**
+ * @covers CachedBagOStuff::doGet
+ */
public function testCacheBackendMisses() {
$backend = new HashBagOStuff;
$cache = new CachedBagOStuff( $backend );
*/
class HashBagOStuffTest extends PHPUnit_Framework_TestCase {
+ /**
+ * @covers HashBagOStuff::delete
+ */
public function testDelete() {
$cache = new HashBagOStuff();
for ( $i = 0; $i < 10; $i++ ) {
}
}
+ /**
+ * @covers HashBagOStuff::clear
+ */
public function testClear() {
$cache = new HashBagOStuff();
for ( $i = 0; $i < 10; $i++ ) {
}
}
+ /**
+ * @covers HashBagOStuff::doGet
+ * @covers HashBagOStuff::expire
+ */
public function testExpire() {
$cache = new HashBagOStuff();
$cacheInternal = TestingAccessWrapper::newFromObject( $cache );
/**
* Ensure maxKeys eviction prefers keeping new keys.
+ *
+ * @covers HashBagOStuff::__construct
+ * @covers HashBagOStuff::set
*/
public function testEvictionAdd() {
$cache = new HashBagOStuff( [ 'maxKeys' => 10 ] );
/**
* Ensure maxKeys eviction prefers recently set keys
* even if the keys pre-exist.
+ *
+ * @covers HashBagOStuff::__construct
+ * @covers HashBagOStuff::set
*/
public function testEvictionSet() {
$cache = new HashBagOStuff( [ 'maxKeys' => 3 ] );
/**
* Ensure maxKeys eviction prefers recently retrieved keys (LRU).
+ *
+ * @covers HashBagOStuff::__construct
+ * @covers HashBagOStuff::doGet
+ * @covers HashBagOStuff::hasKey
*/
public function testEvictionGet() {
$cache = new HashBagOStuff( [ 'maxKeys' => 3 ] );
] );
}
+ /**
+ * @covers MultiWriteBagOStuff::set
+ * @covers MultiWriteBagOStuff::doWrite
+ */
public function testSetImmediate() {
$key = wfRandomString();
$value = wfRandomString();
$this->assertEquals( $value, $this->cache2->get( $key ), 'Written to tier 2' );
}
+ /**
+ * @covers MultiWriteBagOStuff
+ */
public function testSyncMerge() {
$key = wfRandomString();
$value = wfRandomString();
$dbw->commit();
}
+ /**
+ * @covers MultiWriteBagOStuff::set
+ */
public function testSetDelayed() {
$key = wfRandomString();
$value = wfRandomString();