Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 45... Línea 45...
45
    use mod_assign_test_generator;
45
    use mod_assign_test_generator;
Línea 46... Línea 46...
46
 
46
 
47
    /**
47
    /**
48
     * Basic tests for the submission_created() abstract class.
48
     * Basic tests for the submission_created() abstract class.
49
     */
49
     */
50
    public function test_base_event() {
50
    public function test_base_event(): void {
Línea 51... Línea 51...
51
        $this->resetAfterTest();
51
        $this->resetAfterTest();
52
 
52
 
53
        $course = $this->getDataGenerator()->create_course();
53
        $course = $this->getDataGenerator()->create_course();
Línea 72... Línea 72...
72
    }
72
    }
Línea 73... Línea 73...
73
 
73
 
74
    /**
74
    /**
75
     * Basic tests for the submission_created() abstract class.
75
     * Basic tests for the submission_created() abstract class.
76
     */
76
     */
77
    public function test_submission_created() {
77
    public function test_submission_created(): void {
Línea 78... Línea 78...
78
        $this->resetAfterTest();
78
        $this->resetAfterTest();
79
 
79
 
80
        $course = $this->getDataGenerator()->create_course();
80
        $course = $this->getDataGenerator()->create_course();
Línea 132... Línea 132...
132
    }
132
    }
Línea 133... Línea 133...
133
 
133
 
134
    /**
134
    /**
135
     * Basic tests for the submission_updated() abstract class.
135
     * Basic tests for the submission_updated() abstract class.
136
     */
136
     */
137
    public function test_submission_updated() {
137
    public function test_submission_updated(): void {
Línea 138... Línea 138...
138
        $this->resetAfterTest();
138
        $this->resetAfterTest();
139
 
139
 
140
        $course = $this->getDataGenerator()->create_course();
140
        $course = $this->getDataGenerator()->create_course();
Línea 194... Línea 194...
194
    /**
194
    /**
195
     * Test submission_removed event.
195
     * Test submission_removed event.
196
     *
196
     *
197
     * @covers \mod_assign\event\submission_removed
197
     * @covers \mod_assign\event\submission_removed
198
     */
198
     */
199
    public function test_submission_removed() {
199
    public function test_submission_removed(): void {
200
        $this->resetAfterTest();
200
        $this->resetAfterTest();
Línea 201... Línea 201...
201
 
201
 
202
        $course = $this->getDataGenerator()->create_course();
202
        $course = $this->getDataGenerator()->create_course();
203
        $this->getDataGenerator()->create_and_enrol($course, 'teacher');
203
        $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 227... Línea 227...
227
    /**
227
    /**
228
     * Test submission_removed event when a team submission is removed.
228
     * Test submission_removed event when a team submission is removed.
229
     *
229
     *
230
     * @covers \mod_assign\event\submission_removed
230
     * @covers \mod_assign\event\submission_removed
231
     */
231
     */
232
    public function test_team_submission_removed() {
232
    public function test_team_submission_removed(): void {
233
        $this->resetAfterTest();
233
        $this->resetAfterTest();
Línea 234... Línea 234...
234
 
234
 
235
        $course = $this->getDataGenerator()->create_course();
235
        $course = $this->getDataGenerator()->create_course();
236
        $this->getDataGenerator()->create_and_enrol($course, 'teacher');
236
        $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 263... Línea 263...
263
        $this->assertEquals($group->id, $event->other['groupid']);
263
        $this->assertEquals($group->id, $event->other['groupid']);
264
        $this->assertEquals($group->name, $event->other['groupname']);
264
        $this->assertEquals($group->name, $event->other['groupname']);
265
        $sink->close();
265
        $sink->close();
266
    }
266
    }
Línea 267... Línea 267...
267
 
267
 
268
    public function test_extension_granted() {
268
    public function test_extension_granted(): void {
Línea 269... Línea 269...
269
        $this->resetAfterTest();
269
        $this->resetAfterTest();
270
 
270
 
271
        $course = $this->getDataGenerator()->create_course();
271
        $course = $this->getDataGenerator()->create_course();
Línea 294... Línea 294...
294
        $this->assertEquals($assign->get_instance()->id, $event->objectid);
294
        $this->assertEquals($assign->get_instance()->id, $event->objectid);
295
        $this->assertEquals($student->id, $event->relateduserid);
295
        $this->assertEquals($student->id, $event->relateduserid);
296
        $sink->close();
296
        $sink->close();
297
    }
297
    }
Línea 298... Línea 298...
298
 
298
 
299
    public function test_submission_locked() {
299
    public function test_submission_locked(): void {
Línea 300... Línea 300...
300
        $this->resetAfterTest();
300
        $this->resetAfterTest();
301
 
301
 
302
        $course = $this->getDataGenerator()->create_course();
302
        $course = $this->getDataGenerator()->create_course();
Línea 319... Línea 319...
319
        $this->assertEquals($assign->get_instance()->id, $event->objectid);
319
        $this->assertEquals($assign->get_instance()->id, $event->objectid);
320
        $this->assertEquals($student->id, $event->relateduserid);
320
        $this->assertEquals($student->id, $event->relateduserid);
321
        $sink->close();
321
        $sink->close();
322
    }
322
    }
Línea 323... Línea 323...
323
 
323
 
324
    public function test_identities_revealed() {
324
    public function test_identities_revealed(): void {
Línea 325... Línea 325...
325
        $this->resetAfterTest();
325
        $this->resetAfterTest();
326
 
326
 
Línea 352... Línea 352...
352
    }
352
    }
Línea 353... Línea 353...
353
 
353
 
354
    /**
354
    /**
355
     * Test the submission_status_viewed event.
355
     * Test the submission_status_viewed event.
356
     */
356
     */
357
    public function test_submission_status_viewed() {
357
    public function test_submission_status_viewed(): void {
358
        global $PAGE;
358
        global $PAGE;
Línea 359... Línea 359...
359
        $this->resetAfterTest();
359
        $this->resetAfterTest();
360
 
360
 
Línea 383... Línea 383...
383
    /**
383
    /**
384
     * Test submission_status_updated event when a submission is updated.
384
     * Test submission_status_updated event when a submission is updated.
385
     *
385
     *
386
     * @covers \mod_assign\event\submission_status_updated
386
     * @covers \mod_assign\event\submission_status_updated
387
     */
387
     */
388
    public function test_submission_status_updated_on_update() {
388
    public function test_submission_status_updated_on_update(): void {
389
        $this->resetAfterTest();
389
        $this->resetAfterTest();
Línea 390... Línea 390...
390
 
390
 
391
        $course = $this->getDataGenerator()->create_course();
391
        $course = $this->getDataGenerator()->create_course();
392
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
392
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 416... Línea 416...
416
    /**
416
    /**
417
     * Test submission_status_updated event when a submission is removed.
417
     * Test submission_status_updated event when a submission is removed.
418
     *
418
     *
419
     * @covers \mod_assign\event\submission_status_updated
419
     * @covers \mod_assign\event\submission_status_updated
420
     */
420
     */
421
    public function test_submission_status_updated_on_remove() {
421
    public function test_submission_status_updated_on_remove(): void {
422
        $this->resetAfterTest();
422
        $this->resetAfterTest();
Línea 423... Línea 423...
423
 
423
 
424
        $course = $this->getDataGenerator()->create_course();
424
        $course = $this->getDataGenerator()->create_course();
425
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
425
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 447... Línea 447...
447
    /**
447
    /**
448
     * Test submission_status_updated event when a team submission is removed.
448
     * Test submission_status_updated event when a team submission is removed.
449
     *
449
     *
450
     * @covers \mod_assign\event\submission_status_updated
450
     * @covers \mod_assign\event\submission_status_updated
451
     */
451
     */
452
    public function test_team_submission_status_updated_on_remove() {
452
    public function test_team_submission_status_updated_on_remove(): void {
453
        $this->resetAfterTest();
453
        $this->resetAfterTest();
Línea 454... Línea 454...
454
 
454
 
455
        $course = $this->getDataGenerator()->create_course();
455
        $course = $this->getDataGenerator()->create_course();
456
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
456
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 481... Línea 481...
481
        $this->assertEquals(null, $event->relateduserid);
481
        $this->assertEquals(null, $event->relateduserid);
482
        $this->assertEquals(ASSIGN_SUBMISSION_STATUS_NEW, $event->other['newstatus']);
482
        $this->assertEquals(ASSIGN_SUBMISSION_STATUS_NEW, $event->other['newstatus']);
483
        $sink->close();
483
        $sink->close();
484
    }
484
    }
Línea 485... Línea 485...
485
 
485
 
486
    public function test_marker_updated() {
486
    public function test_marker_updated(): void {
Línea 487... Línea 487...
487
        $this->resetAfterTest();
487
        $this->resetAfterTest();
488
 
488
 
489
        $course = $this->getDataGenerator()->create_course();
489
        $course = $this->getDataGenerator()->create_course();
Línea 508... Línea 508...
508
        $this->assertEquals($teacher->id, $event->userid);
508
        $this->assertEquals($teacher->id, $event->userid);
509
        $this->assertEquals($teacher->id, $event->other['markerid']);
509
        $this->assertEquals($teacher->id, $event->other['markerid']);
510
        $sink->close();
510
        $sink->close();
511
    }
511
    }
Línea 512... Línea 512...
512
 
512
 
513
    public function test_workflow_state_updated() {
513
    public function test_workflow_state_updated(): void {
Línea 514... Línea 514...
514
        $this->resetAfterTest();
514
        $this->resetAfterTest();
515
 
515
 
516
        $course = $this->getDataGenerator()->create_course();
516
        $course = $this->getDataGenerator()->create_course();
Línea 586... Línea 586...
586
        $this->assertEquals($teacher->id, $event->userid);
586
        $this->assertEquals($teacher->id, $event->userid);
587
        $this->assertEquals(ASSIGN_MARKING_WORKFLOW_STATE_INMARKING, $event->other['newstate']);
587
        $this->assertEquals(ASSIGN_MARKING_WORKFLOW_STATE_INMARKING, $event->other['newstate']);
588
        $sink->close();
588
        $sink->close();
589
    }
589
    }
Línea 590... Línea 590...
590
 
590
 
591
    public function test_submission_duplicated() {
591
    public function test_submission_duplicated(): void {
Línea 592... Línea 592...
592
        $this->resetAfterTest();
592
        $this->resetAfterTest();
593
 
593
 
Línea 615... Línea 615...
615
        $this->assertEquals($student->id, $event->userid);
615
        $this->assertEquals($student->id, $event->userid);
616
        $submission2->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
616
        $submission2->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
617
        $sink->close();
617
        $sink->close();
618
    }
618
    }
Línea 619... Línea 619...
619
 
619
 
620
    public function test_submission_unlocked() {
620
    public function test_submission_unlocked(): void {
Línea 621... Línea 621...
621
        $this->resetAfterTest();
621
        $this->resetAfterTest();
622
 
622
 
623
        $course = $this->getDataGenerator()->create_course();
623
        $course = $this->getDataGenerator()->create_course();
Línea 640... Línea 640...
640
        $this->assertEquals($assign->get_instance()->id, $event->objectid);
640
        $this->assertEquals($assign->get_instance()->id, $event->objectid);
641
        $this->assertEquals($student->id, $event->relateduserid);
641
        $this->assertEquals($student->id, $event->relateduserid);
642
        $sink->close();
642
        $sink->close();
643
    }
643
    }
Línea 644... Línea 644...
644
 
644
 
645
    public function test_submission_graded() {
645
    public function test_submission_graded(): void {
Línea 646... Línea 646...
646
        $this->resetAfterTest();
646
        $this->resetAfterTest();
647
 
647
 
648
        $course = $this->getDataGenerator()->create_course();
648
        $course = $this->getDataGenerator()->create_course();
Línea 712... Línea 712...
712
    }
712
    }
Línea 713... Línea 713...
713
 
713
 
714
    /**
714
    /**
715
     * Test the submission_viewed event.
715
     * Test the submission_viewed event.
716
     */
716
     */
717
    public function test_submission_viewed() {
717
    public function test_submission_viewed(): void {
Línea 718... Línea 718...
718
        global $PAGE;
718
        global $PAGE;
Línea 719... Línea 719...
719
 
719
 
Línea 750... Línea 750...
750
    }
750
    }
Línea 751... Línea 751...
751
 
751
 
752
    /**
752
    /**
753
     * Test the feedback_viewed event.
753
     * Test the feedback_viewed event.
754
     */
754
     */
755
    public function test_feedback_viewed() {
755
    public function test_feedback_viewed(): void {
Línea 756... Línea 756...
756
        global $DB, $PAGE;
756
        global $DB, $PAGE;
Línea 757... Línea 757...
757
 
757
 
Línea 795... Línea 795...
795
    }
795
    }
Línea 796... Línea 796...
796
 
796
 
797
    /**
797
    /**
798
     * Test the grading_form_viewed event.
798
     * Test the grading_form_viewed event.
799
     */
799
     */
800
    public function test_grading_form_viewed() {
800
    public function test_grading_form_viewed(): void {
Línea 801... Línea 801...
801
        global $PAGE;
801
        global $PAGE;
Línea 802... Línea 802...
802
 
802
 
Línea 830... Línea 830...
830
    }
830
    }
Línea 831... Línea 831...
831
 
831
 
832
    /**
832
    /**
833
     * Test the grading_table_viewed event.
833
     * Test the grading_table_viewed event.
834
     */
834
     */
835
    public function test_grading_table_viewed() {
835
    public function test_grading_table_viewed(): void {
Línea 836... Línea 836...
836
        global $PAGE;
836
        global $PAGE;
Línea 837... Línea 837...
837
 
837
 
Línea 866... Línea 866...
866
    }
866
    }
Línea 867... Línea 867...
867
 
867
 
868
    /**
868
    /**
869
     * Test the submission_form_viewed event.
869
     * Test the submission_form_viewed event.
870
     */
870
     */
871
    public function test_submission_form_viewed() {
871
    public function test_submission_form_viewed(): void {
Línea 872... Línea 872...
872
        global $PAGE;
872
        global $PAGE;
Línea 873... Línea 873...
873
 
873
 
Línea 897... Línea 897...
897
    }
897
    }
Línea 898... Línea 898...
898
 
898
 
899
    /**
899
    /**
900
     * Test the submission_form_viewed event.
900
     * Test the submission_form_viewed event.
901
     */
901
     */
902
    public function test_submission_confirmation_form_viewed() {
902
    public function test_submission_confirmation_form_viewed(): void {
Línea 903... Línea 903...
903
        global $PAGE;
903
        global $PAGE;
Línea 904... Línea 904...
904
 
904
 
Línea 928... Línea 928...
928
    }
928
    }
Línea 929... Línea 929...
929
 
929
 
930
    /**
930
    /**
931
     * Test the reveal_identities_confirmation_page_viewed event.
931
     * Test the reveal_identities_confirmation_page_viewed event.
932
     */
932
     */
933
    public function test_reveal_identities_confirmation_page_viewed() {
933
    public function test_reveal_identities_confirmation_page_viewed(): void {
934
        global $PAGE;
934
        global $PAGE;
Línea 935... Línea 935...
935
        $this->resetAfterTest();
935
        $this->resetAfterTest();
936
 
936
 
Línea 957... Línea 957...
957
    }
957
    }
Línea 958... Línea 958...
958
 
958
 
959
    /**
959
    /**
960
     * Test the statement_accepted event.
960
     * Test the statement_accepted event.
961
     */
961
     */
962
    public function test_statement_accepted() {
962
    public function test_statement_accepted(): void {
963
        // We want to be a student so we can submit assignments.
963
        // We want to be a student so we can submit assignments.
Línea 964... Línea 964...
964
        $this->resetAfterTest();
964
        $this->resetAfterTest();
965
 
965
 
Línea 1021... Línea 1021...
1021
    }
1021
    }
Línea 1022... Línea 1022...
1022
 
1022
 
1023
    /**
1023
    /**
1024
     * Test the batch_set_workflow_state_viewed event.
1024
     * Test the batch_set_workflow_state_viewed event.
1025
     */
1025
     */
1026
    public function test_batch_set_workflow_state_viewed() {
1026
    public function test_batch_set_workflow_state_viewed(): void {
Línea 1027... Línea 1027...
1027
        $this->resetAfterTest();
1027
        $this->resetAfterTest();
1028
 
1028
 
1029
        $course = $this->getDataGenerator()->create_course();
1029
        $course = $this->getDataGenerator()->create_course();
Línea 1043... Línea 1043...
1043
    }
1043
    }
Línea 1044... Línea 1044...
1044
 
1044
 
1045
    /**
1045
    /**
1046
     * Test the batch_set_marker_allocation_viewed event.
1046
     * Test the batch_set_marker_allocation_viewed event.
1047
     */
1047
     */
1048
    public function test_batch_set_marker_allocation_viewed() {
1048
    public function test_batch_set_marker_allocation_viewed(): void {
Línea 1049... Línea 1049...
1049
        $this->resetAfterTest();
1049
        $this->resetAfterTest();
1050
 
1050
 
1051
        $course = $this->getDataGenerator()->create_course();
1051
        $course = $this->getDataGenerator()->create_course();
Línea 1068... Línea 1068...
1068
     * Test the user override created event.
1068
     * Test the user override created event.
1069
     *
1069
     *
1070
     * There is no external API for creating a user override, so the unit test will simply
1070
     * There is no external API for creating a user override, so the unit test will simply
1071
     * create and trigger the event and ensure the event data is returned as expected.
1071
     * create and trigger the event and ensure the event data is returned as expected.
1072
     */
1072
     */
1073
    public function test_user_override_created() {
1073
    public function test_user_override_created(): void {
1074
        $this->resetAfterTest();
1074
        $this->resetAfterTest();
Línea 1075... Línea 1075...
1075
 
1075
 
1076
        $course = $this->getDataGenerator()->create_course();
1076
        $course = $this->getDataGenerator()->create_course();
Línea 1102... Línea 1102...
1102
     * Test the group override created event.
1102
     * Test the group override created event.
1103
     *
1103
     *
1104
     * There is no external API for creating a group override, so the unit test will simply
1104
     * There is no external API for creating a group override, so the unit test will simply
1105
     * create and trigger the event and ensure the event data is returned as expected.
1105
     * create and trigger the event and ensure the event data is returned as expected.
1106
     */
1106
     */
1107
    public function test_group_override_created() {
1107
    public function test_group_override_created(): void {
1108
        $this->resetAfterTest();
1108
        $this->resetAfterTest();
Línea 1109... Línea 1109...
1109
 
1109
 
1110
        $course = $this->getDataGenerator()->create_course();
1110
        $course = $this->getDataGenerator()->create_course();
Línea 1136... Línea 1136...
1136
     * Test the user override updated event.
1136
     * Test the user override updated event.
1137
     *
1137
     *
1138
     * There is no external API for updating a user override, so the unit test will simply
1138
     * There is no external API for updating a user override, so the unit test will simply
1139
     * create and trigger the event and ensure the event data is returned as expected.
1139
     * create and trigger the event and ensure the event data is returned as expected.
1140
     */
1140
     */
1141
    public function test_user_override_updated() {
1141
    public function test_user_override_updated(): void {
1142
        $this->resetAfterTest();
1142
        $this->resetAfterTest();
Línea 1143... Línea 1143...
1143
 
1143
 
1144
        $course = $this->getDataGenerator()->create_course();
1144
        $course = $this->getDataGenerator()->create_course();
Línea 1170... Línea 1170...
1170
     * Test the group override updated event.
1170
     * Test the group override updated event.
1171
     *
1171
     *
1172
     * There is no external API for updating a group override, so the unit test will simply
1172
     * There is no external API for updating a group override, so the unit test will simply
1173
     * create and trigger the event and ensure the event data is returned as expected.
1173
     * create and trigger the event and ensure the event data is returned as expected.
1174
     */
1174
     */
1175
    public function test_group_override_updated() {
1175
    public function test_group_override_updated(): void {
1176
        $this->resetAfterTest();
1176
        $this->resetAfterTest();
Línea 1177... Línea 1177...
1177
 
1177
 
1178
        $course = $this->getDataGenerator()->create_course();
1178
        $course = $this->getDataGenerator()->create_course();
Línea 1201... Línea 1201...
1201
    }
1201
    }
Línea 1202... Línea 1202...
1202
 
1202
 
1203
    /**
1203
    /**
1204
     * Test the user override deleted event.
1204
     * Test the user override deleted event.
1205
     */
1205
     */
1206
    public function test_user_override_deleted() {
1206
    public function test_user_override_deleted(): void {
1207
        global $DB;
1207
        global $DB;
Línea 1208... Línea 1208...
1208
        $this->resetAfterTest();
1208
        $this->resetAfterTest();
1209
 
1209
 
Línea 1232... Línea 1232...
1232
    }
1232
    }
Línea 1233... Línea 1233...
1233
 
1233
 
1234
    /**
1234
    /**
1235
     * Test the group override deleted event.
1235
     * Test the group override deleted event.
1236
     */
1236
     */
1237
    public function test_group_override_deleted() {
1237
    public function test_group_override_deleted(): void {
1238
        global $DB;
1238
        global $DB;
Línea 1239... Línea 1239...
1239
        $this->resetAfterTest();
1239
        $this->resetAfterTest();
1240
 
1240
 
Línea 1263... Línea 1263...
1263
    }
1263
    }
Línea 1264... Línea 1264...
1264
 
1264
 
1265
    /**
1265
    /**
1266
     * Test the course module viewed event.
1266
     * Test the course module viewed event.
1267
     */
1267
     */
1268
    public function test_course_module_viewed() {
1268
    public function test_course_module_viewed(): void {
Línea 1269... Línea 1269...
1269
        $this->resetAfterTest();
1269
        $this->resetAfterTest();
1270
 
1270
 
Línea 1293... Línea 1293...
1293
    }
1293
    }
Línea 1294... Línea 1294...
1294
 
1294
 
1295
    /**
1295
    /**
1296
     * Test that all events generated with blindmarking enabled are anonymous
1296
     * Test that all events generated with blindmarking enabled are anonymous
1297
     */
1297
     */
1298
    public function test_anonymous_events() {
1298
    public function test_anonymous_events(): void {
Línea 1299... Línea 1299...
1299
        $this->resetAfterTest();
1299
        $this->resetAfterTest();
1300
 
1300
 
1301
        $course = $this->getDataGenerator()->create_course();
1301
        $course = $this->getDataGenerator()->create_course();