19 $this->assertAttributeEquals( [],
'cache',
$cache, $msg );
27 for ( $i = 1; $i <= $numEntries; $i++ ) {
28 $cache->set(
"cache-key-$i",
"prop-$i",
"value-$i" );
39 if ( $entryToFill === 0 ) {
42 } elseif ( $entryToFill <= $cacheMaxEntries ) {
47 $firstKey = 1 + $entryToFill - $cacheMaxEntries;
50 $lastKey = $entryToFill;
52 for ( $i = $firstKey; $i <= $lastKey; $i++ ) {
53 $expected[
"cache-key-$i"] = [
"prop-$i" =>
"value-$i" ];
63 $one = [
'A' => 1,
'B' => 2 ];
64 $two = [
'B' => 2,
'A' => 1 ];
66 $this->assertEquals( $one, $two );
68 $this->assertNotSame( $one, $two );
104 $oneCache->set(
'cache-key',
'prop1',
'value1' );
105 $this->assertEquals( 1, $oneCache->getEntriesCount() );
106 $this->assertTrue( $oneCache->has(
'cache-key',
'prop1' ) );
107 $this->assertEquals(
'value1', $oneCache->get(
'cache-key',
'prop1' ) );
118 $oneCache->set(
'cache-key',
'prop1',
'value1' );
119 $oneCache->set(
'cache-key',
'prop1',
'value2' );
120 $this->assertEquals(
'value2', $oneCache->get(
'cache-key',
'prop1' ) );
140 "Filling a $cacheMaxEntries entries cache with $entryToFill entries"
173 $cache->set(
"cache-key-1",
"prop-1",
"new-value-for-1" );
177 'cache-key-2' => [
'prop-2' =>
'value-2' ],
178 'cache-key-1' => [
'prop-1' =>
'new-value-for-1' ],
191 $cache->set(
'first',
'prop1',
'value1' );
192 $cache->set(
'second',
'prop2',
'value2' );
195 $cache->get(
'first',
'prop1' );
197 $cache->set(
'third',
'prop3',
'value3' );
199 $this->assertFalse(
$cache->has(
'second',
'prop2' ) );
218 $cache->set(
"cache-key-2",
"prop-2",
"new-value-for-2" );
221 'cache-key-1' => [
'prop-1' =>
'value-1' ],
222 'cache-key-3' => [
'prop-3' =>
'value-3' ],
223 'cache-key-2' => [
'prop-2' =>
'new-value-for-2' ],
227 $this->assertEquals(
'new-value-for-2',
228 $cache->get(
'cache-key-2',
'prop-2' )
240 $cache->set(
"cache-key-1",
"prop-1",
"new value for 1" );
243 'cache-key-2' => [
'prop-2' =>
'value-2' ],
244 'cache-key-3' => [
'prop-3' =>
'value-3' ],
245 'cache-key-1' => [
'prop-1' =>
'new value for 1' ],
263 return count( $this->
cache );
testRecentlyAccessedKeyStickIn()
ProcessCacheLRU::get ProcessCacheLRU::set ProcessCacheLRU::has.
assertCacheEmpty($cache, $msg= 'Cache should be empty')
Helper to verify emptiness of a cache object.
static provideCacheFilling()
Provider for testFillingCache.
testDeleteOldKey()
ProcessCacheLRU::set ProcessCacheLRU::get.
Overrides some ProcessCacheLRU methods and properties accessibility.
testReplaceExistingKeyInAFullCacheShouldBumpToTop()
This first create a full cache then update the value for the 2nd filled entry.
testConstructorGivenInvalidValue($maxSize)
provideInvalidConstructorArg Wikimedia\Assert\ParameterAssertionException ProcessCacheLRU::__construc...
testReplaceExistingKeyShouldBumpEntryToTop()
Create a cache with only one remaining entry then update the first inserted entry.
you have access to all of the normal MediaWiki so you can get a DB use the cache
testPhpUnitArrayEquality()
Highlight diff between assertEquals and assertNotSame.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Test for ProcessCacheLRU class.
static provideInvalidConstructorArg()
Value which are forbidden by the constructor.
testAddAndGetAKey()
ProcessCacheLRU::get ProcessCacheLRU::set ProcessCacheLRU::has.
fillCache(&$cache, $numEntries)
Helper to fill a cache object passed by reference.
getExpectedCache($cacheMaxEntries, $entryToFill)
Generates an array of what would be expected in cache for a given cache size and a number of entries ...
Handles per process caching of items.
testBumpExistingKeyToTop()
ProcessCacheLRU::set.
testFillingCache($cacheMaxEntries, $entryToFill, $msg= '')
This test that we properly overflow when filling a cache with a sequence of always different cache-ke...