当前位置: 首页>>代码示例>>PHP>>正文


PHP core_user::reset_internal_users方法代码示例

本文整理汇总了PHP中core_user::reset_internal_users方法的典型用法代码示例。如果您正苦于以下问题:PHP core_user::reset_internal_users方法的具体用法?PHP core_user::reset_internal_users怎么用?PHP core_user::reset_internal_users使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_user的用法示例。


在下文中一共展示了core_user::reset_internal_users方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reset_all_data

 /**
  * Reset contents of all database tables to initial values, reset caches, etc.
  *
  * Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
  *
  * @static
  * @param bool $detectchanges
  *      true  - changes in global state and database are reported as errors
  *      false - no errors reported
  *      null  - only critical problems are reported as errors
  * @return void
  */
 public static function reset_all_data($detectchanges = false)
 {
     global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
     // Stop any message redirection.
     phpunit_util::stop_message_redirection();
     // Stop any message redirection.
     phpunit_util::stop_phpmailer_redirection();
     // Stop any message redirection.
     phpunit_util::stop_event_redirection();
     // We used to call gc_collect_cycles here to ensure desctructors were called between tests.
     // This accounted for 25% of the total time running phpunit - so we removed it.
     // Show any unhandled debugging messages, the runbare() could already reset it.
     self::display_debugging_messages();
     self::reset_debugging();
     // reset global $DB in case somebody mocked it
     $DB = self::get_global_backup('DB');
     if ($DB->is_transaction_started()) {
         // we can not reset inside transaction
         $DB->force_transaction_rollback();
     }
     $resetdb = self::reset_database();
     $warnings = array();
     if ($detectchanges === true) {
         if ($resetdb) {
             $warnings[] = 'Warning: unexpected database modification, resetting DB state';
         }
         $oldcfg = self::get_global_backup('CFG');
         $oldsite = self::get_global_backup('SITE');
         foreach ($CFG as $k => $v) {
             if (!property_exists($oldcfg, $k)) {
                 $warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
             } else {
                 if ($oldcfg->{$k} !== $CFG->{$k}) {
                     $warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
                 }
             }
             unset($oldcfg->{$k});
         }
         if ($oldcfg) {
             foreach ($oldcfg as $k => $v) {
                 $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 (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');
     $_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);
     filter_manager::reset_caches();
     // Reset internal users.
     core_user::reset_internal_users();
     //TODO MDL-25290: add more resets here and probably refactor them to new core function
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:util.php

示例2: test_get_user

 public function test_get_user()
 {
     global $CFG;
     $this->resetAfterTest(true);
     // Create user and try fetach it with api.
     $user = $this->getDataGenerator()->create_user();
     $this->assertEquals($user, core_user::get_user($user->id, '*', MUST_EXIST));
     // Test noreply user.
     $CFG->noreplyuserid = null;
     $noreplyuser = core_user::get_noreply_user();
     $this->assertEquals(1, $noreplyuser->emailstop);
     $this->assertFalse(core_user::is_real_user($noreplyuser->id));
     $this->assertEquals($CFG->noreplyaddress, $noreplyuser->email);
     $this->assertEquals(get_string('noreplyname'), $noreplyuser->firstname);
     // Set user as noreply user and make sure noreply propery is set.
     core_user::reset_internal_users();
     $CFG->noreplyuserid = $user->id;
     $noreplyuser = core_user::get_noreply_user();
     $this->assertEquals(1, $noreplyuser->emailstop);
     $this->assertTrue(core_user::is_real_user($noreplyuser->id));
     // Test support user.
     core_user::reset_internal_users();
     $CFG->supportemail = null;
     $CFG->noreplyuserid = null;
     $supportuser = core_user::get_support_user();
     $adminuser = get_admin();
     $this->assertEquals($adminuser, $supportuser);
     $this->assertTrue(core_user::is_real_user($supportuser->id));
     // When supportemail is set.
     core_user::reset_internal_users();
     $CFG->supportemail = 'test@support.moodle.test';
     $supportuser = core_user::get_support_user();
     $this->assertEquals(core_user::SUPPORT_USER, $supportuser->id);
     $this->assertFalse(core_user::is_real_user($supportuser->id));
     // Set user as support user and make sure noreply propery is set.
     core_user::reset_internal_users();
     $CFG->supportuserid = $user->id;
     $supportuser = core_user::get_support_user();
     $this->assertEquals($user, $supportuser);
     $this->assertTrue(core_user::is_real_user($supportuser->id));
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:41,代码来源:user_test.php

示例3: test_message_get_contacts

 /**
  * Test message_get_contacts.
  */
 public function test_message_get_contacts()
 {
     global $USER, $CFG;
     // Set this user as the admin.
     $this->setAdminUser();
     $noreplyuser = core_user::get_noreply_user();
     $supportuser = core_user::get_support_user();
     // Create a user to add to the admin's contact list.
     $user1 = $this->getDataGenerator()->create_user();
     $user2 = $this->getDataGenerator()->create_user();
     $user3 = $this->getDataGenerator()->create_user();
     // Stranger.
     // Add users to the admin's contact list.
     message_add_contact($user1->id);
     message_add_contact($user2->id);
     // Send some messages.
     $this->send_fake_message($user1, $USER);
     $this->send_fake_message($user2, $USER);
     $this->send_fake_message($user3, $USER);
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(2, $offlinecontacts);
     $this->assertCount(1, $strangers);
     // Send message from noreply and support users.
     $this->send_fake_message($noreplyuser, $USER);
     $this->send_fake_message($supportuser, $USER);
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(2, $offlinecontacts);
     $this->assertCount(3, $strangers);
     // Block 1 user.
     message_block_contact($user2->id);
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(1, $offlinecontacts);
     $this->assertCount(3, $strangers);
     // Noreply user being valid user.
     core_user::reset_internal_users();
     $CFG->noreplyuserid = $user3->id;
     $noreplyuser = core_user::get_noreply_user();
     list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts();
     $this->assertCount(0, $onlinecontacts);
     $this->assertCount(1, $offlinecontacts);
     $this->assertCount(2, $strangers);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:48,代码来源:messagelib_test.php


注:本文中的core_user::reset_internal_users方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。