Esempio n. 1
0
 /**
  * Test the group override updated event.
  *
  * There is no external API for updating a group override, so the unit test will simply
  * create and trigger the event and ensure the event data is returned as expected.
  */
 public function test_group_override_updated()
 {
     $params = array('objectid' => 1, 'context' => context_module::instance($this->lesson->properties()->cmid), 'other' => array('lessonid' => $this->lesson->id, 'groupid' => 2));
     $event = \mod_lesson\event\group_override_updated::create($params);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\mod_lesson\\event\\group_override_updated', $event);
     $this->assertEquals(context_module::instance($this->lesson->properties()->cmid), $event->get_context());
     $this->assertEventContextNotUsed($event);
 }
Esempio n. 2
0
         $lesson->delete_override($oldoverride->id);
     }
 }
 // Set the common parameters for one of the events we may be triggering.
 $params = array('context' => $context, 'other' => array('lessonid' => $lesson->id));
 if (!empty($override->id)) {
     $fromform->id = $override->id;
     $DB->update_record('lesson_overrides', $fromform);
     // Determine which override updated event to fire.
     $params['objectid'] = $override->id;
     if (!$groupmode) {
         $params['relateduserid'] = $fromform->userid;
         $event = \mod_lesson\event\user_override_updated::create($params);
     } else {
         $params['other']['groupid'] = $fromform->groupid;
         $event = \mod_lesson\event\group_override_updated::create($params);
     }
     // Trigger the override updated event.
     $event->trigger();
 } else {
     unset($fromform->id);
     $fromform->id = $DB->insert_record('lesson_overrides', $fromform);
     // Determine which override created event to fire.
     $params['objectid'] = $fromform->id;
     if (!$groupmode) {
         $params['relateduserid'] = $fromform->userid;
         $event = \mod_lesson\event\user_override_created::create($params);
     } else {
         $params['other']['groupid'] = $fromform->groupid;
         $event = \mod_lesson\event\group_override_created::create($params);
     }