Skip to content

Commit

Permalink
Merge branch 'MDL-49581_m30v4' of https://github.com/sbourget/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 29, 2015
2 parents 8b56685 + 58459ff commit ad913a2
Showing 1 changed file with 0 additions and 75 deletions.
75 changes: 0 additions & 75 deletions mod/lesson/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,81 +199,6 @@ public function test_essay_attempt_viewed() {
$this->assertEventContextNotUsed($event);
}

/**
* Test the highscore added event.
*
* There is no external API for adding a highscore, so the unit test will simply create
* and trigger the event and ensure the legacy log data is returned as expected.
*/
public function test_highscore_added() {
global $DB;

// Create a highscore.
$newhighscore = new stdClass;
$newhighscore->lessonid = $this->lesson->id;
$newhighscore->userid = 3;
$newhighscore->gradeid = 70;
$newhighscore->nickname = 'noob';

$newhighscore->id = $DB->insert_record('lesson_high_scores', $newhighscore);

// Create a highscore added event.
$event = \mod_lesson\event\highscore_added::create(array(
'objectid' => $newhighscore->id,
'context' => context_module::instance($this->lesson->properties()->cmid),
'courseid' => $this->course->id,
'other' => array(
'lessonid' => $this->lesson->id,
'nickname' => 'noob'
)
));

// 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\highscore_added', $event);
$this->assertEquals(context_module::instance($this->lesson->properties()->cmid), $event->get_context());
$expected = array($this->course->id, 'lesson', 'update highscores', 'highscores.php?id=' . $this->lesson->properties()->cmid,
'noob', $this->lesson->properties()->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingCalled();
}

/**
* Test the highscores viewed event.
*
* There is no external API for viewing highscores, so the unit test will simply create
* and trigger the event and ensure the legacy log data is returned as expected.
*/
public function test_highscores_viewed() {
// Create a highscore viewed event.
$event = \mod_lesson\event\highscores_viewed::create(array(
'objectid' => $this->lesson->id,
'context' => context_module::instance($this->lesson->properties()->cmid),
'courseid' => $this->course->id
));

// 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\highscores_viewed', $event);
$this->assertEquals(context_module::instance($this->lesson->properties()->cmid), $event->get_context());
$expected = array($this->course->id, 'lesson', 'view highscores', 'highscores.php?id=' . $this->lesson->properties()->cmid,
$this->lesson->properties()->name, $this->lesson->properties()->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingCalled();
}

/**
* Test the lesson started event.
*/
Expand Down

0 comments on commit ad913a2

Please sign in to comment.