/** * Test instances_list_viewed event. */ public function test_course_module_instance_list_viewed() { // There is no proper API to call or trigger this event, so simulating event // to check if event returns the right information. $this->setUp(); $context = context_course::instance($this->course->id); $params = array('context' => $context); $event = \mod_wiki\event\course_module_instance_list_viewed::create($params); // Triggering and capturing the event. $sink = $this->redirectEvents(); $event->trigger(); $events = $sink->get_events(); $this->assertCount(1, $events); $event = reset($events); // Checking that the event contains the expected values. $this->assertInstanceOf('\\mod_wiki\\event\\course_module_instance_list_viewed', $event); $this->assertEquals($context, $event->get_context()); $expected = array($this->course->id, 'wiki', 'view all', 'index.php?id=' . $this->course->id, ''); $this->assertEventLegacyLogData($expected, $event); $this->assertEventContextNotUsed($event); }
* @author Kenneth Riba * * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once '../../config.php'; require_once 'lib.php'; $id = required_param('id', PARAM_INT); // course $PAGE->set_url('/mod/wiki/index.php', array('id' => $id)); if (!($course = $DB->get_record('course', array('id' => $id)))) { print_error('invalidcourseid'); } require_login($course, true); $PAGE->set_pagelayout('incourse'); $context = context_course::instance($course->id); $event = \mod_wiki\event\course_module_instance_list_viewed::create(array('context' => $context)); $event->trigger(); /// Get all required stringswiki $strwikis = get_string("modulenameplural", "wiki"); $strwiki = get_string("modulename", "wiki"); /// Print the header $PAGE->navbar->add($strwikis, "index.php?id={$course->id}"); $PAGE->set_title($strwikis); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->heading($strwikis); /// Get all the appropriate data if (!($wikis = get_all_instances_in_course("wiki", $course))) { notice("There are no wikis", "../../course/view.php?id={$course->id}"); die; }