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


PHP subscriptions::fetch_subscription_cache方法代碼示例

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


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

示例1: test_discussion_subscription_cache_fill_for_course

 /**
  * Test that the discussion subscription cache can filled course-at-a-time.
  */
 public function test_discussion_subscription_cache_fill_for_course()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create a course, with a forum.
     $course = $this->getDataGenerator()->create_course();
     // Create the forums.
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE);
     $disallowforum = $this->getDataGenerator()->create_module('forum', $options);
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_CHOOSESUBSCRIBE);
     $chooseforum = $this->getDataGenerator()->create_module('forum', $options);
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_INITIALSUBSCRIBE);
     $initialforum = $this->getDataGenerator()->create_module('forum', $options);
     // Create some users and keep a reference to the first user.
     $users = $this->helper_create_users($course, 20);
     $user = reset($users);
     // Reset the subscription caches.
     \mod_forum\subscriptions::reset_forum_cache();
     $startcount = $DB->perf_get_reads();
     $result = \mod_forum\subscriptions::fill_subscription_cache_for_course($course->id, $user->id);
     $this->assertNull($result);
     $postfillcount = $DB->perf_get_reads();
     $this->assertEquals(1, $postfillcount - $startcount);
     $this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($disallowforum->id, $user->id));
     $this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($chooseforum->id, $user->id));
     $this->assertTrue(\mod_forum\subscriptions::fetch_subscription_cache($initialforum->id, $user->id));
     $finalcount = $DB->perf_get_reads();
     $this->assertEquals(0, $finalcount - $postfillcount);
     // Test for all users.
     foreach ($users as $user) {
         $result = \mod_forum\subscriptions::fill_subscription_cache_for_course($course->id, $user->id);
         $this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($disallowforum->id, $user->id));
         $this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($chooseforum->id, $user->id));
         $this->assertTrue(\mod_forum\subscriptions::fetch_subscription_cache($initialforum->id, $user->id));
     }
     $finalcount = $DB->perf_get_reads();
     $this->assertEquals(count($users), $finalcount - $postfillcount);
 }
開發者ID:Jinelle,項目名稱:moodle,代碼行數:41,代碼來源:subscriptions_test.php


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