MDL-56273 cache: Use cache initialise always.

purge_all() and purge_by_definition() look in the configuration
for which caches are available and then creates them to purge them.
The configuration stores the values used by initialise(), not
initialise_unit_test_instance() and would therefore fail to purge
all caches if they were not purged by another means.

In the case of filestore, it's purged by unit tests, in the case
of memcache(d), it purges the whole store when a single definition
is requested.

Therefore all configuration was moved into the configuration file
during unit tests and does not have any special override codes in
the unit test infrastructure.
This commit is contained in:
Russell Smith
2016-10-30 13:42:43 +11:00
parent 577bd70d38
commit a169739d5d
18 changed files with 123 additions and 147 deletions
+3 -21
View File
@@ -81,15 +81,11 @@ interface cache_store_interface {
public static function initialise_test_instance(cache_definition $definition);
/**
* Initialises a test instance for unit tests.
* Generates the appropriate configuration required for unit testing.
*
* This differs from initialise_test_instance in that it doesn't rely on interacting with the config table.
*
* @since 2.8
* @param cache_definition $definition
* @return cache_store|false
* @return array Array of unit test configuration data to be used by initialise().
*/
public static function initialise_unit_test_instance(cache_definition $definition);
public static function unit_test_configuration();
}
/**
@@ -369,20 +365,6 @@ abstract class cache_store implements cache_store_interface {
return clone($this);
}
/**
* Initialises a test instance for unit tests.
*
* This differs from initialise_test_instance in that it doesn't rely on interacting with the config table.
* By default however it calls initialise_test_instance to support backwards compatibility.
*
* @since 2.8
* @param cache_definition $definition
* @return cache_store|false
*/
public static function initialise_unit_test_instance(cache_definition $definition) {
return static::initialise_test_instance($definition);
}
/**
* Can be overridden to return any warnings this store instance should make to the admin.
*