mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-43294 mod_lesson: Unit test for essay_assessed event.
This commit is contained in:
parent
f577148266
commit
b481cc2e8f
@ -194,4 +194,39 @@ class mod_lesson_events_testcase extends advanced_testcase {
|
||||
$this->lesson->properties()->id, $this->lesson->properties()->cmid);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the essay assessed event.
|
||||
*
|
||||
* There is no external API for assessing an essay, so the unit test will simply
|
||||
* create and trigger the event and ensure the legacy log data is returned as expected.
|
||||
*/
|
||||
public function test_essay_assessed() {
|
||||
// Create an essay assessed event
|
||||
$gradeid = 5;
|
||||
$attemptid = 7;
|
||||
$event = \mod_lesson\event\essay_assessed::create(array(
|
||||
'objectid' => $gradeid,
|
||||
'relateduserid' => 3,
|
||||
'context' => context_module::instance($this->lesson->properties()->cmid),
|
||||
'courseid' => $this->course->id,
|
||||
'other' => array(
|
||||
'lessonid' => $this->lesson->id,
|
||||
'attemptid' => $attemptid
|
||||
)
|
||||
));
|
||||
|
||||
// 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\essay_assessed', $event);
|
||||
$this->assertEquals(context_module::instance($this->lesson->properties()->cmid), $event->get_context());
|
||||
$expected = array($this->course->id, 'lesson', 'update grade', 'essay.php?id=' . $this->lesson->properties()->cmid,
|
||||
$this->lesson->name, $this->lesson->properties()->cmid);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user