本文整理汇总了PHP中question_edit_contexts::having_cap方法的典型用法代码示例。如果您正苦于以下问题:PHP question_edit_contexts::having_cap方法的具体用法?PHP question_edit_contexts::having_cap怎么用?PHP question_edit_contexts::having_cap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_edit_contexts
的用法示例。
在下文中一共展示了question_edit_contexts::having_cap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_question_category_created
/**
* Test the question category created event.
*/
public function test_question_category_created()
{
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
$quiz = $this->getDataGenerator()->create_module('quiz', array('course' => $course->id));
$contexts = new question_edit_contexts(context_module::instance($quiz->cmid));
$defaultcategoryobj = question_make_default_categories(array($contexts->lowest()));
$defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid;
$qcobject = new question_category_object(1, new moodle_url('/mod/quiz/edit.php', array('cmid' => $quiz->cmid)), $contexts->having_one_edit_tab_cap('categories'), $defaultcategoryobj->id, $defaultcategory, null, $contexts->having_cap('moodle/question:add'));
// Trigger and capture the event.
$sink = $this->redirectEvents();
$categoryid = $qcobject->add_category($defaultcategory, 'newcategory', '', true);
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\\core\\event\\question_category_created', $event);
$this->assertEquals(context_module::instance($quiz->cmid), $event->get_context());
$expected = array($course->id, 'quiz', 'addcategory', 'view.php?id=' . $quiz->cmid, $categoryid, $quiz->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
}