本文整理汇总了PHP中core_user::reset_caches方法的典型用法代码示例。如果您正苦于以下问题:PHP core_user::reset_caches方法的具体用法?PHP core_user::reset_caches怎么用?PHP core_user::reset_caches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_user
的用法示例。
在下文中一共展示了core_user::reset_caches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset_all_data
//.........这里部分代码省略.........
$warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
}
}
if ($USER->id != 0) {
$warnings[] = 'Warning: unexpected change of $USER';
}
if ($COURSE->id != $oldsite->id) {
$warnings[] = 'Warning: unexpected change of $COURSE';
}
if ($FULLME !== self::get_global_backup('FULLME')) {
$warnings[] = 'Warning: unexpected change of $FULLME';
}
if (setlocale(LC_TIME, 0) !== $localename) {
$warnings[] = 'Warning: unexpected change of locale';
}
}
if (ini_get('max_execution_time') != 0) {
// This is special warning for all resets because we do not want any
// libraries to mess with timeouts unintentionally.
// Our PHPUnit integration is not supposed to change it either.
if ($detectchanges !== false) {
$warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
}
set_time_limit(0);
}
// restore original globals
$_SERVER = self::get_global_backup('_SERVER');
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
$FULLME = self::get_global_backup('FULLME');
$_GET = array();
$_POST = array();
$_FILES = array();
$_REQUEST = array();
$COURSE = $SITE;
// reinitialise following globals
$OUTPUT = new bootstrap_renderer();
$PAGE = new moodle_page();
$FULLME = null;
$ME = null;
$SCRIPT = null;
// Empty sessison and set fresh new not-logged-in user.
\core\session\manager::init_empty_session();
// reset all static caches
\core\event\manager::phpunit_reset();
accesslib_clear_all_caches(true);
get_string_manager()->reset_caches(true);
reset_text_filters_cache(true);
events_get_handlers('reset');
core_text::reset_caches();
get_message_processors(false, true, true);
filter_manager::reset_caches();
core_filetypes::reset_caches();
core_user::reset_caches();
// Reset static unit test options.
if (class_exists('\\availability_date\\condition', false)) {
\availability_date\condition::set_current_time_for_test(0);
}
// Reset internal users.
core_user::reset_internal_users();
//TODO MDL-25290: add more resets here and probably refactor them to new core function
// Reset course and module caches.
if (class_exists('format_base')) {
// If file containing class is not loaded, there is no cache there anyway.
format_base::reset_course_cache(0);
}
get_fast_modinfo(0, 0, true);
// Reset other singletons.
if (class_exists('core_plugin_manager')) {
core_plugin_manager::reset_caches(true);
}
if (class_exists('\\core\\update\\checker')) {
\core\update\checker::reset_caches(true);
}
// Clear static cache within restore.
if (class_exists('restore_section_structure_step')) {
restore_section_structure_step::reset_caches();
}
// purge dataroot directory
self::reset_dataroot();
// restore original config once more in case resetting of caches changed CFG
$CFG = self::get_global_backup('CFG');
// inform data generator
self::get_data_generator()->reset();
// fix PHP settings
error_reporting($CFG->debug);
// Reset the date/time class.
core_date::phpunit_reset();
// Make sure the time locale is consistent - that is Australian English.
setlocale(LC_TIME, $localename);
// verify db writes just in case something goes wrong in reset
if (self::$lastdbwrites != $DB->perf_get_writes()) {
error_log('Unexpected DB writes in phpunit_util::reset_all_data()');
self::$lastdbwrites = $DB->perf_get_writes();
}
if ($warnings) {
$warnings = implode("\n", $warnings);
trigger_error($warnings, E_USER_WARNING);
}
}
示例2: test_get_property_default
/**
* Test get_property_default().
*
*
* @expectedException coding_exception
* @expectedExceptionMessage Invalid property requested, or the property does not has a default value.
*/
public function test_get_property_default()
{
global $CFG;
$this->resetAfterTest();
$country = core_user::get_property_default('country');
$this->assertEquals($CFG->country, $country);
set_config('country', 'AU');
core_user::reset_caches();
$country = core_user::get_property_default('country');
$this->assertEquals($CFG->country, $country);
$lang = core_user::get_property_default('lang');
$this->assertEquals($CFG->lang, $lang);
set_config('lang', 'en');
$lang = core_user::get_property_default('lang');
$this->assertEquals($CFG->lang, $lang);
$this->setTimezone('Europe/London', 'Pacific/Auckland');
core_user::reset_caches();
$timezone = core_user::get_property_default('timezone');
$this->assertEquals('Europe/London', $timezone);
$this->setTimezone('99', 'Pacific/Auckland');
core_user::reset_caches();
$timezone = core_user::get_property_default('timezone');
$this->assertEquals('Pacific/Auckland', $timezone);
core_user::get_property_default('firstname');
}
示例3: test_get_property_default
/**
* Test get_property_default().
*/
public function test_get_property_default()
{
global $CFG;
$this->resetAfterTest();
$country = core_user::get_property_default('country');
$this->assertEquals($CFG->country, $country);
set_config('country', 'AU');
core_user::reset_caches();
$country = core_user::get_property_default('country');
$this->assertEquals($CFG->country, $country);
$lang = core_user::get_property_default('lang');
$this->assertEquals($CFG->lang, $lang);
set_config('lang', 'en');
$lang = core_user::get_property_default('lang');
$this->assertEquals($CFG->lang, $lang);
$this->setTimezone('Europe/London', 'Pacific/Auckland');
core_user::reset_caches();
$timezone = core_user::get_property_default('timezone');
$this->assertEquals('Europe/London', $timezone);
$this->setTimezone('99', 'Pacific/Auckland');
core_user::reset_caches();
$timezone = core_user::get_property_default('timezone');
$this->assertEquals('Pacific/Auckland', $timezone);
$this->setExpectedException('coding_exception', 'Invalid property requested, or the property does not has a default value.');
core_user::get_property_default('firstname');
}