本文整理汇总了PHP中calendar_get_course_cached函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_get_course_cached函数的具体用法?PHP calendar_get_course_cached怎么用?PHP calendar_get_course_cached使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_get_course_cached函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_calendar_get_course_cached
public function test_calendar_get_course_cached()
{
// Setup some test courses.
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$course3 = $this->getDataGenerator()->create_course();
// Load courses into cache.
$coursecache = null;
calendar_get_course_cached($coursecache, $course1->id);
calendar_get_course_cached($coursecache, $course2->id);
calendar_get_course_cached($coursecache, $course3->id);
// Verify the cache.
$this->assertArrayHasKey($course1->id, $coursecache);
$cachedcourse1 = $coursecache[$course1->id];
$this->assertEquals($course1->id, $cachedcourse1->id);
$this->assertEquals($course1->shortname, $cachedcourse1->shortname);
$this->assertEquals($course1->fullname, $cachedcourse1->fullname);
$this->assertArrayHasKey($course2->id, $coursecache);
$cachedcourse2 = $coursecache[$course2->id];
$this->assertEquals($course2->id, $cachedcourse2->id);
$this->assertEquals($course2->shortname, $cachedcourse2->shortname);
$this->assertEquals($course2->fullname, $cachedcourse2->fullname);
$this->assertArrayHasKey($course3->id, $coursecache);
$cachedcourse3 = $coursecache[$course3->id];
$this->assertEquals($course3->id, $cachedcourse3->id);
$this->assertEquals($course3->shortname, $cachedcourse3->shortname);
$this->assertEquals($course3->fullname, $cachedcourse3->fullname);
}
示例2: calendar_get_module_cached
function calendar_get_module_cached(&$coursecache, $modulename, $instance)
{
$module = get_coursemodule_from_instance($modulename, $instance);
if ($module === false) {
return false;
}
if (!calendar_get_course_cached($coursecache, $module->course)) {
return false;
}
return $module;
}