Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 59... Línea 59...
59
 
59
 
60
    /**
60
    /**
61
     * Test the page created event.
61
     * Test the page created event.
62
     *
62
     *
63
     */
63
     */
Línea 64... Línea 64...
64
    public function test_page_created() {
64
    public function test_page_created(): void {
65
 
65
 
66
        // Set up a generator to create content.
66
        // Set up a generator to create content.
67
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_lesson');
67
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_lesson');
Línea 83... Línea 83...
83
 
83
 
84
    /**
84
    /**
85
     * Test the page created event.
85
     * Test the page created event.
86
     *
86
     *
87
     */
87
     */
Línea 88... Línea 88...
88
    public function test_page_moved() {
88
    public function test_page_moved(): void {
89
 
89
 
90
        // Set up a generator to create content.
90
        // Set up a generator to create content.
91
        // paga3 is the first one and page1 the last one.
91
        // paga3 is the first one and page1 the last one.
Línea 115... Línea 115...
115
 
115
 
116
    /**
116
    /**
117
     * Test the page deleted event.
117
     * Test the page deleted event.
118
     *
118
     *
119
     */
119
     */
Línea 120... Línea 120...
120
    public function test_page_deleted() {
120
    public function test_page_deleted(): void {
121
 
121
 
122
        // Set up a generator to create content.
122
        // Set up a generator to create content.
123
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_lesson');
123
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_lesson');
Línea 144... Línea 144...
144
     * Test the page updated event.
144
     * Test the page updated event.
145
     *
145
     *
146
     * There is no external API for updateing a page, so the unit test will simply
146
     * There is no external API for updateing a page, so the unit test will simply
147
     * create and trigger the event and ensure data is returned as expected.
147
     * create and trigger the event and ensure data is returned as expected.
148
     */
148
     */
149
    public function test_page_updated() {
149
    public function test_page_updated(): void {
Línea 150... Línea 150...
150
 
150
 
151
        // Trigger an event: page updated.
151
        // Trigger an event: page updated.
152
        $eventparams = array(
152
        $eventparams = array(
153
            'context' => \context_module::instance($this->lesson->properties()->cmid),
153
            'context' => \context_module::instance($this->lesson->properties()->cmid),
Línea 177... Línea 177...
177
     * Test the essay attempt viewed event.
177
     * Test the essay attempt viewed event.
178
     *
178
     *
179
     * There is no external API for viewing an essay attempt, so the unit test will simply
179
     * There is no external API for viewing an essay attempt, so the unit test will simply
180
     * create and trigger the event and ensure the legacy log data is returned as expected.
180
     * create and trigger the event and ensure the legacy log data is returned as expected.
181
     */
181
     */
182
    public function test_essay_attempt_viewed() {
182
    public function test_essay_attempt_viewed(): void {
183
        // Create a essays list viewed event
183
        // Create a essays list viewed event
184
        $event = \mod_lesson\event\essay_attempt_viewed::create(array(
184
        $event = \mod_lesson\event\essay_attempt_viewed::create(array(
185
            'objectid' => $this->lesson->id,
185
            'objectid' => $this->lesson->id,
186
            'relateduserid' => 3,
186
            'relateduserid' => 3,
187
            'context' => \context_module::instance($this->lesson->properties()->cmid),
187
            'context' => \context_module::instance($this->lesson->properties()->cmid),
Línea 201... Línea 201...
201
    }
201
    }
Línea 202... Línea 202...
202
 
202
 
203
    /**
203
    /**
204
     * Test the lesson started event.
204
     * Test the lesson started event.
205
     */
205
     */
206
    public function test_lesson_started() {
206
    public function test_lesson_started(): void {
207
        // Trigger and capture the event.
207
        // Trigger and capture the event.
208
        $sink = $this->redirectEvents();
208
        $sink = $this->redirectEvents();
209
        $this->lesson->start_timer();
209
        $this->lesson->start_timer();
210
        $events = $sink->get_events();
210
        $events = $sink->get_events();
Línea 217... Línea 217...
217
    }
217
    }
Línea 218... Línea 218...
218
 
218
 
219
    /**
219
    /**
220
     * Test the lesson restarted event.
220
     * Test the lesson restarted event.
221
     */
221
     */
Línea 222... Línea 222...
222
    public function test_lesson_restarted() {
222
    public function test_lesson_restarted(): void {
223
 
223
 
224
        // Initialize timer.
224
        // Initialize timer.
225
        $this->lesson->start_timer();
225
        $this->lesson->start_timer();
Línea 240... Línea 240...
240
    }
240
    }
Línea 241... Línea 241...
241
 
241
 
242
    /**
242
    /**
243
     * Test the lesson restarted event.
243
     * Test the lesson restarted event.
244
     */
244
     */
Línea 245... Línea 245...
245
    public function test_lesson_resumed() {
245
    public function test_lesson_resumed(): void {
246
 
246
 
247
        // Initialize timer.
247
        // Initialize timer.
248
        $this->lesson->start_timer();
248
        $this->lesson->start_timer();
Línea 262... Línea 262...
262
 
262
 
263
    }
263
    }
264
    /**
264
    /**
265
     * Test the lesson ended event.
265
     * Test the lesson ended event.
266
     */
266
     */
267
    public function test_lesson_ended() {
267
    public function test_lesson_ended(): void {
Línea 268... Línea 268...
268
        global $DB, $USER;
268
        global $DB, $USER;
269
 
269
 
270
        // Add a lesson timer so that stop_timer() does not complain.
270
        // Add a lesson timer so that stop_timer() does not complain.
Línea 291... Línea 291...
291
     * Test the essay assessed event.
291
     * Test the essay assessed event.
292
     *
292
     *
293
     * There is no external API for assessing an essay, so the unit test will simply
293
     * There is no external API for assessing an essay, so the unit test will simply
294
     * create and trigger the event and ensure the legacy log data is returned as expected.
294
     * create and trigger the event and ensure the legacy log data is returned as expected.
295
     */
295
     */
296
    public function test_essay_assessed() {
296
    public function test_essay_assessed(): void {
297
        // Create an essay assessed event
297
        // Create an essay assessed event
298
        $gradeid = 5;
298
        $gradeid = 5;
299
        $attemptid = 7;
299
        $attemptid = 7;
300
        $event = \mod_lesson\event\essay_assessed::create(array(
300
        $event = \mod_lesson\event\essay_assessed::create(array(
301
            'objectid' => $gradeid,
301
            'objectid' => $gradeid,
Línea 322... Línea 322...
322
 
322
 
323
    /**
323
    /**
324
     * Test the content page viewed event.
324
     * Test the content page viewed event.
325
     *
325
     *
326
     */
326
     */
327
    public function test_content_page_viewed() {
327
    public function test_content_page_viewed(): void {
Línea 328... Línea 328...
328
        global $DB, $PAGE;
328
        global $DB, $PAGE;
329
 
329
 
330
        // Set up a generator to create content.
330
        // Set up a generator to create content.
Línea 356... Línea 356...
356
 
356
 
357
    /**
357
    /**
358
     * Test the question viewed event.
358
     * Test the question viewed event.
359
     *
359
     *
360
     */
360
     */
361
    public function test_question_viewed() {
361
    public function test_question_viewed(): void {
Línea 362... Línea 362...
362
        global $DB, $PAGE;
362
        global $DB, $PAGE;
363
 
363
 
364
        // Set up a generator to create content.
364
        // Set up a generator to create content.
Línea 393... Línea 393...
393
     * Test the question answered event.
393
     * Test the question answered event.
394
     *
394
     *
395
     * There is no external API for answering an truefalse question, so the unit test will simply
395
     * There is no external API for answering an truefalse question, so the unit test will simply
396
     * create and trigger the event and ensure data is returned as expected.
396
     * create and trigger the event and ensure data is returned as expected.
397
     */
397
     */
398
    public function test_question_answered() {
398
    public function test_question_answered(): void {
Línea 399... Línea 399...
399
 
399
 
400
        // Trigger an event: truefalse question answered.
400
        // Trigger an event: truefalse question answered.
401
        $eventparams = array(
401
        $eventparams = array(
402
            'context' => \context_module::instance($this->lesson->properties()->cmid),
402
            'context' => \context_module::instance($this->lesson->properties()->cmid),
Línea 426... Línea 426...
426
     * Test the user override created event.
426
     * Test the user override created event.
427
     *
427
     *
428
     * There is no external API for creating a user override, so the unit test will simply
428
     * There is no external API for creating a user override, so the unit test will simply
429
     * create and trigger the event and ensure the event data is returned as expected.
429
     * create and trigger the event and ensure the event data is returned as expected.
430
     */
430
     */
431
    public function test_user_override_created() {
431
    public function test_user_override_created(): void {
Línea 432... Línea 432...
432
 
432
 
433
        $params = array(
433
        $params = array(
434
            'objectid' => 1,
434
            'objectid' => 1,
435
            'relateduserid' => 2,
435
            'relateduserid' => 2,
Línea 456... Línea 456...
456
     * Test the group override created event.
456
     * Test the group override created event.
457
     *
457
     *
458
     * There is no external API for creating a group override, so the unit test will simply
458
     * There is no external API for creating a group override, so the unit test will simply
459
     * create and trigger the event and ensure the event data is returned as expected.
459
     * create and trigger the event and ensure the event data is returned as expected.
460
     */
460
     */
461
    public function test_group_override_created() {
461
    public function test_group_override_created(): void {
Línea 462... Línea 462...
462
 
462
 
463
        $params = array(
463
        $params = array(
464
            'objectid' => 1,
464
            'objectid' => 1,
465
            'context' => \context_module::instance($this->lesson->properties()->cmid),
465
            'context' => \context_module::instance($this->lesson->properties()->cmid),
Línea 486... Línea 486...
486
     * Test the user override updated event.
486
     * Test the user override updated event.
487
     *
487
     *
488
     * There is no external API for updating a user override, so the unit test will simply
488
     * There is no external API for updating a user override, so the unit test will simply
489
     * create and trigger the event and ensure the event data is returned as expected.
489
     * create and trigger the event and ensure the event data is returned as expected.
490
     */
490
     */
491
    public function test_user_override_updated() {
491
    public function test_user_override_updated(): void {
Línea 492... Línea 492...
492
 
492
 
493
        $params = array(
493
        $params = array(
494
            'objectid' => 1,
494
            'objectid' => 1,
495
            'relateduserid' => 2,
495
            'relateduserid' => 2,
Línea 516... Línea 516...
516
     * Test the group override updated event.
516
     * Test the group override updated event.
517
     *
517
     *
518
     * There is no external API for updating a group override, so the unit test will simply
518
     * There is no external API for updating a group override, so the unit test will simply
519
     * create and trigger the event and ensure the event data is returned as expected.
519
     * create and trigger the event and ensure the event data is returned as expected.
520
     */
520
     */
521
    public function test_group_override_updated() {
521
    public function test_group_override_updated(): void {
Línea 522... Línea 522...
522
 
522
 
523
        $params = array(
523
        $params = array(
524
            'objectid' => 1,
524
            'objectid' => 1,
525
            'context' => \context_module::instance($this->lesson->properties()->cmid),
525
            'context' => \context_module::instance($this->lesson->properties()->cmid),
Línea 543... Línea 543...
543
    }
543
    }
Línea 544... Línea 544...
544
 
544
 
545
    /**
545
    /**
546
     * Test the user override deleted event.
546
     * Test the user override deleted event.
547
     */
547
     */
548
    public function test_user_override_deleted() {
548
    public function test_user_override_deleted(): void {
Línea 549... Línea 549...
549
        global $DB;
549
        global $DB;
550
 
550
 
551
        // Create an override.
551
        // Create an override.
Línea 567... Línea 567...
567
    }
567
    }
Línea 568... Línea 568...
568
 
568
 
569
    /**
569
    /**
570
     * Test the group override deleted event.
570
     * Test the group override deleted event.
571
     */
571
     */
572
    public function test_group_override_deleted() {
572
    public function test_group_override_deleted(): void {
Línea 573... Línea 573...
573
        global $DB;
573
        global $DB;
574
 
574
 
575
        // Create an override.
575
        // Create an override.