本文整理汇总了PHP中core_availability\info_module::is_available方法的典型用法代码示例。如果您正苦于以下问题:PHP info_module::is_available方法的具体用法?PHP info_module::is_available怎么用?PHP info_module::is_available使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_availability\info_module
的用法示例。
在下文中一共展示了info_module::is_available方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_info_module
/**
* Tests the info_module class (is_available, get_full_information).
*/
public function test_info_module()
{
global $DB;
// Create a course and pages.
$this->setAdminUser();
$this->resetAfterTest();
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$rec = array('course' => $course);
$page1 = $generator->get_plugin_generator('mod_page')->create_instance($rec);
$page2 = $generator->get_plugin_generator('mod_page')->create_instance($rec);
$page3 = $generator->get_plugin_generator('mod_page')->create_instance($rec);
$page4 = $generator->get_plugin_generator('mod_page')->create_instance($rec);
// Set up the availability option for the pages to mock options.
$DB->set_field('course_modules', 'availability', '{"op":"|","show":true,"c":[' . '{"type":"mock","a":false,"m":"grandmaster flash"}]}', array('id' => $page1->cmid));
$DB->set_field('course_modules', 'availability', '{"op":"|","show":true,"c":[' . '{"type":"mock","a":true,"m":"the furious five"}]}', array('id' => $page2->cmid));
// Third page is invalid. (Fourth has no availability settings.)
$DB->set_field('course_modules', 'availability', '{{{', array('id' => $page3->cmid));
$modinfo = get_fast_modinfo($course);
$cm1 = $modinfo->get_cm($page1->cmid);
$cm2 = $modinfo->get_cm($page2->cmid);
$cm3 = $modinfo->get_cm($page3->cmid);
$cm4 = $modinfo->get_cm($page4->cmid);
// Do availability and full information checks.
$info = new info_module($cm1);
$information = '';
$this->assertFalse($info->is_available($information));
$this->assertEquals('SA: grandmaster flash', $information);
$this->assertEquals('SA: [FULL]grandmaster flash', $info->get_full_information());
$info = new info_module($cm2);
$this->assertTrue($info->is_available($information));
$this->assertEquals('', $information);
$this->assertEquals('SA: [FULL]the furious five', $info->get_full_information());
// Check invalid one.
$info = new info_module($cm3);
$this->assertFalse($info->is_available($information));
$debugging = phpunit_util::get_debugging_messages();
phpunit_util::reset_debugging();
$this->assertEquals(1, count($debugging));
$this->assertContains('Invalid availability', $debugging[0]->message);
// Check empty one.
$info = new info_module($cm4);
$this->assertTrue($info->is_available($information));
$this->assertEquals('', $information);
$this->assertEquals('', $info->get_full_information());
}