Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'MDL-62364_master' of git://github.com/markn86/moodle
  • Loading branch information
David Monllao authored and junpataleta committed May 10, 2018
2 parents 6fe7510 + b6b7c26 commit a49a438
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/classes/event/notification_sent.php
Expand Up @@ -58,6 +58,11 @@ public static function create_from_ids($userfromid, $usertoid, $notificationid,
$userfromid = 0;
}

// If the courseid is null, then set it to the site id.
if (is_null($courseid)) {
$courseid = SITEID;
}

$event = self::create(
[
'objectid' => $notificationid,
Expand Down
17 changes: 17 additions & 0 deletions message/tests/events_test.php
Expand Up @@ -484,6 +484,23 @@ public function test_notification_sent() {
$this->assertEquals($url, $event->get_url());
}

/**
* Test the notification sent event when null passed as course.
*/
public function test_notification_sent_with_null_course() {
$event = \core\event\notification_sent::create_from_ids(1, 1, 1, null);

// 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('\core\event\notification_sent', $event);
$this->assertEquals(SITEID, $event->other['courseid']);
}

/**
* Test the notification viewed event.
*/
Expand Down

0 comments on commit a49a438

Please sign in to comment.