mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-33774 Reset filters caches between unit tests
This commit is contained in:
parent
173115e14c
commit
73a0f3ba76
@ -90,6 +90,25 @@ class filter_manager {
|
||||
return self::$singletoninstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the caches, usually to be called between unit tests
|
||||
*/
|
||||
public static function reset_caches() {
|
||||
if (self::$singletoninstance) {
|
||||
self::$singletoninstance->unload_all_filters();
|
||||
}
|
||||
self::$singletoninstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads all filters and other cached information
|
||||
*/
|
||||
protected function unload_all_filters() {
|
||||
$this->textfilters = array();
|
||||
$this->stringfilters = array();
|
||||
$this->stringfilternames = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all the filters required by this context.
|
||||
*
|
||||
@ -286,6 +305,16 @@ class performance_measuring_filter_manager extends filter_manager {
|
||||
protected $textsfiltered = 0;
|
||||
protected $stringsfiltered = 0;
|
||||
|
||||
/**
|
||||
* Unloads all filters and other cached information
|
||||
*/
|
||||
protected function unload_all_filters() {
|
||||
parent::unload_all_filters();
|
||||
$this->filterscreated = 0;
|
||||
$this->textsfiltered = 0;
|
||||
$this->stringsfiltered = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filtername
|
||||
* @param object $context
|
||||
|
@ -171,6 +171,7 @@ class phpunit_util extends testing_util {
|
||||
if (class_exists('repository')) {
|
||||
repository::reset_caches();
|
||||
}
|
||||
filter_manager::reset_caches();
|
||||
//TODO MDL-25290: add more resets here and probably refactor them to new core function
|
||||
|
||||
// Reset course and module caches.
|
||||
|
Loading…
x
Reference in New Issue
Block a user