2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Tests for h5p deleted event.
22 * @copyright 2019 Carlos Escobedo <carlos@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') ||
die();
29 use core_h5p\local\library\autoloader
;
32 * Tests for h5p deleted event.
36 * @copyright 2019 Carlos Escobedo <carlos@moodle.com>
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40 class core_h5p_event_h5p_deleted_testcase
extends advanced_testcase
{
45 protected function setUp(): void
{
47 autoloader
::register();
51 * test_event_h5p_deleted description
52 * @runInSeparateProcess
54 public function test_event_h5p_deleted() {
55 $this->resetAfterTest(true);
57 $user = $this->getDataGenerator()->create_user();
58 $course = $this->getDataGenerator()->create_course();
59 $page = $this->getDataGenerator()->create_module('page', array('course' => $course->id
));
60 $pagecontext = \context_module
::instance($page->cmid
);
62 // Dummy H5P id for testing proposal. We don't need a real h5p.
65 // Event parameters for testing.
67 'objectid' => $dummyh5pid,
68 'userid' => $user->id
,
69 'context' => $pagecontext,
74 // Prepare redirect Events.
75 $sink = $this->redirectEvents();
76 // Test the event H5P deleted.
77 $event = \core_h5p\event\h5p_deleted
::create($params);
79 $result = $sink->get_events();
80 $event = reset($result);
82 // Check the event info.
83 $this->assertEquals($dummyh5pid, $event->objectid
);
84 $this->assertEquals($user->id
, $event->userid
);
85 $this->assertEquals($pagecontext->id
, $event->contextid
);
86 $this->assertEquals($now, $event->other
['time']);