當前位置: 首頁>>代碼示例>>PHP>>正文


PHP subscriptions::reset_discussion_cache方法代碼示例

本文整理匯總了PHP中mod_forum\subscriptions::reset_discussion_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP subscriptions::reset_discussion_cache方法的具體用法?PHP subscriptions::reset_discussion_cache怎麽用?PHP subscriptions::reset_discussion_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mod_forum\subscriptions的用法示例。


在下文中一共展示了subscriptions::reset_discussion_cache方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 /**
  * Set up message and mail sinks, and set up other requirements for the
  * cron to be tested here.
  */
 public function setUp()
 {
     global $CFG;
     $this->helper = new stdClass();
     // Messaging is not compatible with transactions...
     $this->preventResetByRollback();
     // Catch all messages
     $this->helper->messagesink = $this->redirectMessages();
     $this->helper->mailsink = $this->redirectEmails();
     // Confirm that we have an empty message sink so far.
     $messages = $this->helper->messagesink->get_messages();
     $this->assertEquals(0, count($messages));
     $messages = $this->helper->mailsink->get_messages();
     $this->assertEquals(0, count($messages));
     // Tell Moodle that we've not sent any digest messages out recently.
     $CFG->digestmailtimelast = 0;
     // And set the digest sending time to a negative number - this has
     // the effect of making it 11pm the previous day.
     $CFG->digestmailtime = -1;
     // Forcibly reduce the maxeditingtime to a one second to ensure that
     // messages are sent out.
     $CFG->maxeditingtime = 1;
     // We must clear the subscription caches. This has to be done both before each test, and after in case of other
     // tests using these functions.
     \mod_forum\subscriptions::reset_forum_cache();
     \mod_forum\subscriptions::reset_discussion_cache();
 }
開發者ID:alanaipe2015,項目名稱:moodle,代碼行數:31,代碼來源:maildigest_test.php

示例2: setUp

 public function setUp()
 {
     // We must clear the subscription caches. This has to be done both before each test, and after in case of other
     // tests using these functions.
     \mod_forum\subscriptions::reset_forum_cache();
     \mod_forum\subscriptions::reset_discussion_cache();
     global $CFG;
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     $helper = new stdClass();
     // Messaging is not compatible with transactions...
     $this->preventResetByRollback();
     // Catch all messages.
     $helper->messagesink = $this->redirectMessages();
     $helper->mailsink = $this->redirectEmails();
     // Confirm that we have an empty message sink so far.
     $messages = $helper->messagesink->get_messages();
     $this->assertEquals(0, count($messages));
     $messages = $helper->mailsink->get_messages();
     $this->assertEquals(0, count($messages));
     // Forcibly reduce the maxeditingtime to a second in the past to
     // ensure that messages are sent out.
     $CFG->maxeditingtime = -1;
     // Ensure that we don't prevent e-mail as this will cause unit test failures.
     $CFG->noemailever = false;
     $this->helper = $helper;
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:26,代碼來源:mail_test.php

示例3: test_discussion_subscription_cache_fill

 /**
  * Test that the discussion subscription cache can filled user-at-a-time.
  */
 public function test_discussion_subscription_cache_fill()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create a course, with a forum.
     $course = $this->getDataGenerator()->create_course();
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_INITIALSUBSCRIBE);
     $forum = $this->getDataGenerator()->create_module('forum', $options);
     // Create some users.
     $users = $this->helper_create_users($course, 20);
     // Post some discussions to the forum.
     $discussions = array();
     $author = $users[0];
     for ($i = 0; $i < 20; $i++) {
         list($discussion, $post) = $this->helper_post_to_forum($forum, $author);
         $discussions[] = $discussion;
     }
     // Unsubscribe half the users from the half the discussions.
     $forumcount = 0;
     $usercount = 0;
     foreach ($discussions as $data) {
         if ($forumcount % 2) {
             continue;
         }
         foreach ($users as $user) {
             if ($usercount % 2) {
                 continue;
             }
             \mod_forum\subscriptions::unsubscribe_user_from_discussion($user->id, $discussion);
             $usercount++;
         }
         $forumcount++;
     }
     // Reset the subscription caches.
     \mod_forum\subscriptions::reset_forum_cache();
     \mod_forum\subscriptions::reset_discussion_cache();
     $startcount = $DB->perf_get_reads();
     // Now fetch some subscriptions from that forum - these should use
     // the cache and not perform additional queries.
     foreach ($users as $user) {
         $result = \mod_forum\subscriptions::fetch_discussion_subscription($forum->id, $user->id);
         $this->assertInternalType('array', $result);
     }
     $finalcount = $DB->perf_get_reads();
     $this->assertEquals(20, $finalcount - $startcount);
 }
開發者ID:Jinelle,項目名稱:moodle,代碼行數:49,代碼來源:subscriptions_test.php


注:本文中的mod_forum\subscriptions::reset_discussion_cache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。