MediaWiki  1.32.5
ProcessCacheLRUTest Class Reference

Test for ProcessCacheLRU class. More...

Inheritance diagram for ProcessCacheLRUTest:
Collaboration diagram for ProcessCacheLRUTest:

Public Member Functions

 testAddAndGetAKey ()
 ProcessCacheLRU::get ProcessCacheLRU::set ProcessCacheLRU::has. More...
 
 testBumpExistingKeyToTop ()
 ProcessCacheLRU::set. More...
 
 testConstructorGivenInvalidValue ( $maxSize)
 provideInvalidConstructorArg Wikimedia\Assert\ParameterAssertionException ProcessCacheLRU::__construct More...
 
 testDeleteOldKey ()
 ProcessCacheLRU::set ProcessCacheLRU::get. More...
 
 testFillingCache ( $cacheMaxEntries, $entryToFill, $msg='')
 This test that we properly overflow when filling a cache with a sequence of always different cache-keys. More...
 
 testPhpUnitArrayEquality ()
 Highlight diff between assertEquals and assertNotSame @coversNothing. More...
 
 testRecentlyAccessedKeyStickIn ()
 ProcessCacheLRU::get ProcessCacheLRU::set ProcessCacheLRU::has. More...
 
 testReplaceExistingKeyInAFullCacheShouldBumpToTop ()
 This first create a full cache then update the value for the 2nd filled entry. More...
 
 testReplaceExistingKeyShouldBumpEntryToTop ()
 Create a cache with only one remaining entry then update the first inserted entry. More...
 

Static Public Member Functions

static provideCacheFilling ()
 Provider for testFillingCache. More...
 
static provideInvalidConstructorArg ()
 Value which are forbidden by the constructor. More...
 

Protected Member Functions

 assertCacheEmpty ( $cache, $msg='Cache should be empty')
 Helper to verify emptiness of a cache object. More...
 
 fillCache (&$cache, $numEntries)
 Helper to fill a cache object passed by reference. More...
 
 getExpectedCache ( $cacheMaxEntries, $entryToFill)
 Generates an array of what would be expected in cache for a given cache size and a number of entries filled in sequentially. More...
 

Detailed Description

Test for ProcessCacheLRU class.

Note that it uses the ProcessCacheLRUTestable class which extends some properties and methods visibility. That class is defined at the end of the file containing this class.

Cache

Definition at line 12 of file ProcessCacheLRUTest.php.

Member Function Documentation

◆ assertCacheEmpty()

ProcessCacheLRUTest::assertCacheEmpty (   $cache,
  $msg = 'Cache should be empty' 
)
protected

Helper to verify emptiness of a cache object.

Compare against an array so we get the cache content difference.

Definition at line 20 of file ProcessCacheLRUTest.php.

References $cache.

Referenced by testAddAndGetAKey(), and testDeleteOldKey().

◆ fillCache()

ProcessCacheLRUTest::fillCache ( $cache,
  $numEntries 
)
protected

Helper to fill a cache object passed by reference.

Definition at line 27 of file ProcessCacheLRUTest.php.

References $cache.

Referenced by testBumpExistingKeyToTop(), testFillingCache(), testReplaceExistingKeyInAFullCacheShouldBumpToTop(), and testReplaceExistingKeyShouldBumpEntryToTop().

◆ getExpectedCache()

ProcessCacheLRUTest::getExpectedCache (   $cacheMaxEntries,
  $entryToFill 
)
protected

Generates an array of what would be expected in cache for a given cache size and a number of entries filled in sequentially.

Definition at line 38 of file ProcessCacheLRUTest.php.

Referenced by testFillingCache().

◆ provideCacheFilling()

static ProcessCacheLRUTest::provideCacheFilling ( )
static

Provider for testFillingCache.

Definition at line 150 of file ProcessCacheLRUTest.php.

◆ provideInvalidConstructorArg()

static ProcessCacheLRUTest::provideInvalidConstructorArg ( )
static

Value which are forbidden by the constructor.

Definition at line 86 of file ProcessCacheLRUTest.php.

◆ testAddAndGetAKey()

ProcessCacheLRUTest::testAddAndGetAKey ( )

◆ testBumpExistingKeyToTop()

ProcessCacheLRUTest::testBumpExistingKeyToTop ( )

ProcessCacheLRU::set.

Definition at line 238 of file ProcessCacheLRUTest.php.

References $cache, and fillCache().

◆ testConstructorGivenInvalidValue()

ProcessCacheLRUTest::testConstructorGivenInvalidValue (   $maxSize)

provideInvalidConstructorArg Wikimedia\Assert\ParameterAssertionException ProcessCacheLRU::__construct

Definition at line 79 of file ProcessCacheLRUTest.php.

◆ testDeleteOldKey()

ProcessCacheLRUTest::testDeleteOldKey ( )

◆ testFillingCache()

ProcessCacheLRUTest::testFillingCache (   $cacheMaxEntries,
  $entryToFill,
  $msg = '' 
)

This test that we properly overflow when filling a cache with a sequence of always different cache-keys.

Meant to verify we correclty delete the older key.

ProcessCacheLRU::set provideCacheFilling

Parameters
int$cacheMaxEntriesMaximum entry the created cache will hold
int$entryToFillNumber of entries to insert in the created cache.

Definition at line 136 of file ProcessCacheLRUTest.php.

References $cache, fillCache(), and getExpectedCache().

◆ testPhpUnitArrayEquality()

ProcessCacheLRUTest::testPhpUnitArrayEquality ( )

Highlight diff between assertEquals and assertNotSame @coversNothing.

Definition at line 65 of file ProcessCacheLRUTest.php.

◆ testRecentlyAccessedKeyStickIn()

ProcessCacheLRUTest::testRecentlyAccessedKeyStickIn ( )

◆ testReplaceExistingKeyInAFullCacheShouldBumpToTop()

ProcessCacheLRUTest::testReplaceExistingKeyInAFullCacheShouldBumpToTop ( )

This first create a full cache then update the value for the 2nd filled entry.

Given a cache having 1,2,3 as key, updating 2 should bump 2 to the top of the queue with the new value: 1,3,2* (* = updated).

ProcessCacheLRU::set ProcessCacheLRU::get

Definition at line 214 of file ProcessCacheLRUTest.php.

References $cache, and fillCache().

◆ testReplaceExistingKeyShouldBumpEntryToTop()

ProcessCacheLRUTest::testReplaceExistingKeyShouldBumpEntryToTop ( )

Create a cache with only one remaining entry then update the first inserted entry.

Should bump it to the top.

ProcessCacheLRU::set

Definition at line 168 of file ProcessCacheLRUTest.php.

References $cache, and fillCache().


The documentation for this class was generated from the following file: