Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 76... Línea 76...
76
     * be return.
76
     * be return.
77
     *
77
     *
78
     * If there are no events on or after the given time then an empty result set should
78
     * If there are no events on or after the given time then an empty result set should
79
     * be returned.
79
     * be returned.
80
     */
80
     */
81
    public function test_get_calendar_action_events_by_timesort_after_time() {
81
    public function test_get_calendar_action_events_by_timesort_after_time(): void {
82
        $user = $this->getDataGenerator()->create_user();
82
        $user = $this->getDataGenerator()->create_user();
83
        $course = $this->getDataGenerator()->create_course();
83
        $course = $this->getDataGenerator()->create_course();
84
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
84
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
85
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
85
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
Línea 132... Línea 132...
132
     * should not be returned.
132
     * should not be returned.
133
     *
133
     *
134
     * If there are no events before the given time then an empty result set should be
134
     * If there are no events before the given time then an empty result set should be
135
     * returned.
135
     * returned.
136
     */
136
     */
137
    public function test_get_calendar_action_events_by_timesort_before_time() {
137
    public function test_get_calendar_action_events_by_timesort_before_time(): void {
138
        $user = $this->getDataGenerator()->create_user();
138
        $user = $this->getDataGenerator()->create_user();
139
        $course = $this->getDataGenerator()->create_course();
139
        $course = $this->getDataGenerator()->create_course();
140
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
140
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
141
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
141
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
Línea 183... Línea 183...
183
     * a sort time between the lower and upper time bound (inclusive).
183
     * a sort time between the lower and upper time bound (inclusive).
184
     *
184
     *
185
     * If there are no events in the given time range then an empty result set should be
185
     * If there are no events in the given time range then an empty result set should be
186
     * returned.
186
     * returned.
187
     */
187
     */
188
    public function test_get_calendar_action_events_by_timesort_time_range() {
188
    public function test_get_calendar_action_events_by_timesort_time_range(): void {
189
        $user = $this->getDataGenerator()->create_user();
189
        $user = $this->getDataGenerator()->create_user();
190
        $course = $this->getDataGenerator()->create_course();
190
        $course = $this->getDataGenerator()->create_course();
191
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
191
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
192
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
192
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
Línea 235... Línea 235...
235
     * and uppper time bound (inclusive) where the result set is shifted by the offset value.
235
     * and uppper time bound (inclusive) where the result set is shifted by the offset value.
236
     *
236
     *
237
     * If there are no events in the given time range then an empty result set should be
237
     * If there are no events in the given time range then an empty result set should be
238
     * returned.
238
     * returned.
239
     */
239
     */
240
    public function test_get_calendar_action_events_by_timesort_time_limit_offset() {
240
    public function test_get_calendar_action_events_by_timesort_time_limit_offset(): void {
241
        $user = $this->getDataGenerator()->create_user();
241
        $user = $this->getDataGenerator()->create_user();
242
        $course = $this->getDataGenerator()->create_course();
242
        $course = $this->getDataGenerator()->create_course();
243
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
243
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
244
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
244
        $moduleinstance = $generator->create_instance(['course' => $course->id]);
Línea 287... Línea 287...
287
 
287
 
288
    /**
288
    /**
289
     * Test get_calendar_action_events_by_timesort with search feature.
289
     * Test get_calendar_action_events_by_timesort with search feature.
290
     * @covers ::get_action_events_by_timesort
290
     * @covers ::get_action_events_by_timesort
291
     */
291
     */
292
    public function test_get_calendar_action_events_by_timesort_with_search() {
292
    public function test_get_calendar_action_events_by_timesort_with_search(): void {
293
        // Generate data.
293
        // Generate data.
294
        $user = $this->getDataGenerator()->create_user();
294
        $user = $this->getDataGenerator()->create_user();
295
        $course = $this->getDataGenerator()->create_course();
295
        $course = $this->getDataGenerator()->create_course();
296
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
296
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
Línea 364... Línea 364...
364
     * to that time should not be return.
364
     * to that time should not be return.
365
     *
365
     *
366
     * If there are no events on or after the given time then an empty result set should
366
     * If there are no events on or after the given time then an empty result set should
367
     * be returned.
367
     * be returned.
368
     */
368
     */
369
    public function test_get_calendar_action_events_by_course_after_time() {
369
    public function test_get_calendar_action_events_by_course_after_time(): void {
370
        $user = $this->getDataGenerator()->create_user();
370
        $user = $this->getDataGenerator()->create_user();
371
        $course1 = $this->getDataGenerator()->create_course();
371
        $course1 = $this->getDataGenerator()->create_course();
372
        $course2 = $this->getDataGenerator()->create_course();
372
        $course2 = $this->getDataGenerator()->create_course();
373
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
373
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
374
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
374
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
Línea 429... Línea 429...
429
     * events after that time should not be returned.
429
     * events after that time should not be returned.
430
     *
430
     *
431
     * If there are no events before the given time then an empty result set should be
431
     * If there are no events before the given time then an empty result set should be
432
     * returned.
432
     * returned.
433
     */
433
     */
434
    public function test_get_calendar_action_events_by_course_before_time() {
434
    public function test_get_calendar_action_events_by_course_before_time(): void {
435
        $user = $this->getDataGenerator()->create_user();
435
        $user = $this->getDataGenerator()->create_user();
436
        $course1 = $this->getDataGenerator()->create_course();
436
        $course1 = $this->getDataGenerator()->create_course();
437
        $course2 = $this->getDataGenerator()->create_course();
437
        $course2 = $this->getDataGenerator()->create_course();
438
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
438
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
439
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
439
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
Línea 494... Línea 494...
494
     * (inclusive).
494
     * (inclusive).
495
     *
495
     *
496
     * If there are no events in the given time range then an empty result set should be
496
     * If there are no events in the given time range then an empty result set should be
497
     * returned.
497
     * returned.
498
     */
498
     */
499
    public function test_get_calendar_action_events_by_course_time_range() {
499
    public function test_get_calendar_action_events_by_course_time_range(): void {
500
        $user = $this->getDataGenerator()->create_user();
500
        $user = $this->getDataGenerator()->create_user();
501
        $course1 = $this->getDataGenerator()->create_course();
501
        $course1 = $this->getDataGenerator()->create_course();
502
        $course2 = $this->getDataGenerator()->create_course();
502
        $course2 = $this->getDataGenerator()->create_course();
503
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
503
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
504
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
504
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
Línea 560... Línea 560...
560
     * set is shifted by the offset value.
560
     * set is shifted by the offset value.
561
     *
561
     *
562
     * If there are no events in the given time range then an empty result set should be
562
     * If there are no events in the given time range then an empty result set should be
563
     * returned.
563
     * returned.
564
     */
564
     */
565
    public function test_get_calendar_action_events_by_course_time_limit_offset() {
565
    public function test_get_calendar_action_events_by_course_time_limit_offset(): void {
566
        $user = $this->getDataGenerator()->create_user();
566
        $user = $this->getDataGenerator()->create_user();
567
        $course1 = $this->getDataGenerator()->create_course();
567
        $course1 = $this->getDataGenerator()->create_course();
568
        $course2 = $this->getDataGenerator()->create_course();
568
        $course2 = $this->getDataGenerator()->create_course();
569
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
569
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
570
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
570
        $moduleinstance1 = $generator->create_instance(['course' => $course1->id]);
Línea 625... Línea 625...
625
 
625
 
626
    /**
626
    /**
627
     * Test that get_action_events_by_courses will return a list of events for each
627
     * Test that get_action_events_by_courses will return a list of events for each
628
     * course you provided as long as the user is enrolled in the course.
628
     * course you provided as long as the user is enrolled in the course.
629
     */
629
     */
630
    public function test_get_action_events_by_courses() {
630
    public function test_get_action_events_by_courses(): void {
631
        $user = $this->getDataGenerator()->create_user();
631
        $user = $this->getDataGenerator()->create_user();
632
        $course1 = $this->getDataGenerator()->create_course();
632
        $course1 = $this->getDataGenerator()->create_course();
633
        $course2 = $this->getDataGenerator()->create_course();
633
        $course2 = $this->getDataGenerator()->create_course();
634
        $course3 = $this->getDataGenerator()->create_course();
634
        $course3 = $this->getDataGenerator()->create_course();
Línea 714... Línea 714...
714
 
714
 
715
    /**
715
    /**
716
     * Test get_action_events_by_courses with search feature.
716
     * Test get_action_events_by_courses with search feature.
717
     * @covers ::get_action_events_by_courses
717
     * @covers ::get_action_events_by_courses
718
     */
718
     */
719
    public function test_get_action_events_by_courses_with_search() {
719
    public function test_get_action_events_by_courses_with_search(): void {
720
        // Generate data.
720
        // Generate data.
721
        $user = $this->getDataGenerator()->create_user();
721
        $user = $this->getDataGenerator()->create_user();
722
        $course1 = $this->getDataGenerator()->create_course(['fullname' => 'Course with advanced name']);
722
        $course1 = $this->getDataGenerator()->create_course(['fullname' => 'Course with advanced name']);
723
        $course2 = $this->getDataGenerator()->create_course(['fullname' => 'Another name']);
723
        $course2 = $this->getDataGenerator()->create_course(['fullname' => 'Another name']);
Línea 785... Línea 785...
785
    }
785
    }
Línea 786... Línea 786...
786
 
786
 
787
    /**
787
    /**
788
     * Test that the get_legacy_events() function only returns activity events that are enabled.
788
     * Test that the get_legacy_events() function only returns activity events that are enabled.
789
     */
789
     */
790
    public function test_get_legacy_events_with_disabled_module() {
790
    public function test_get_legacy_events_with_disabled_module(): void {
Línea 791... Línea 791...
791
        global $DB;
791
        global $DB;
Línea 792... Línea 792...
792
 
792
 
Línea 856... Línea 856...
856
    }
856
    }
Línea 857... Línea 857...
857
 
857
 
858
    /**
858
    /**
859
     * Test for \core_calendar\local\api::get_legacy_events() when there are user and group overrides.
859
     * Test for \core_calendar\local\api::get_legacy_events() when there are user and group overrides.
860
     */
860
     */
861
    public function test_get_legacy_events_with_overrides() {
861
    public function test_get_legacy_events_with_overrides(): void {
Línea 862... Línea 862...
862
        $generator = $this->getDataGenerator();
862
        $generator = $this->getDataGenerator();
Línea 863... Línea 863...
863
 
863
 
Línea 1046... Línea 1046...
1046
 
1046
 
1047
    /**
1047
    /**
1048
     * Setting the start date on the calendar event should update the date
1048
     * Setting the start date on the calendar event should update the date
1049
     * of the event but should leave the time of day unchanged.
1049
     * of the event but should leave the time of day unchanged.
1050
     */
1050
     */
1051
    public function test_update_event_start_day_updates_date() {
1051
    public function test_update_event_start_day_updates_date(): void {
1052
        $generator = $this->getDataGenerator();
1052
        $generator = $this->getDataGenerator();
1053
        $user = $generator->create_user();
1053
        $user = $generator->create_user();
1054
        $roleid = $generator->create_role();
1054
        $roleid = $generator->create_role();
1055
        $context = \context_system::instance();
1055
        $context = \context_system::instance();
Línea 1081... Línea 1081...
1081
 
1081
 
1082
    /**
1082
    /**
1083
     * A user should not be able to update the start date of the event
1083
     * A user should not be able to update the start date of the event
1084
     * that they don't have the capabilities to modify.
1084
     * that they don't have the capabilities to modify.
1085
     */
1085
     */
1086
    public function test_update_event_start_day_no_permission() {
1086
    public function test_update_event_start_day_no_permission(): void {
1087
        $generator = $this->getDataGenerator();
1087
        $generator = $this->getDataGenerator();
1088
        $user = $generator->create_user();
1088
        $user = $generator->create_user();
1089
        $roleid = $generator->create_role();
1089
        $roleid = $generator->create_role();
1090
        $context = \context_system::instance();
1090
        $context = \context_system::instance();
Línea 1117... Línea 1117...
1117
     * update the corresponding activity property.
1117
     * update the corresponding activity property.
1118
     *
1118
     *
1119
     * Note: This test uses the feedback activity because it requires
1119
     * Note: This test uses the feedback activity because it requires
1120
     * module callbacks to be in place to test.
1120
     * module callbacks to be in place to test.
1121
     */
1121
     */
1122
    public function test_update_event_start_day_activity_event_no_max() {
1122
    public function test_update_event_start_day_activity_event_no_max(): void {
1123
        global $CFG, $DB;
1123
        global $CFG, $DB;
1124
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1124
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1125... Línea 1125...
1125
 
1125
 
1126
        $this->resetAfterTest(true);
1126
        $this->resetAfterTest(true);
Línea 1152... Línea 1152...
1152
     * property.
1152
     * property.
1153
     *
1153
     *
1154
     * Note: This test uses the feedback activity because it requires
1154
     * Note: This test uses the feedback activity because it requires
1155
     * module callbacks to be in place to test.
1155
     * module callbacks to be in place to test.
1156
     */
1156
     */
1157
    public function test_update_event_start_day_activity_event_less_than_max() {
1157
    public function test_update_event_start_day_activity_event_less_than_max(): void {
1158
        global $CFG, $DB;
1158
        global $CFG, $DB;
1159
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1159
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1160... Línea 1160...
1160
 
1160
 
1161
        $this->resetAfterTest(true);
1161
        $this->resetAfterTest(true);
Línea 1189... Línea 1189...
1189
     * property.
1189
     * property.
1190
     *
1190
     *
1191
     * Note: This test uses the feedback activity because it requires
1191
     * Note: This test uses the feedback activity because it requires
1192
     * module callbacks to be in place to test.
1192
     * module callbacks to be in place to test.
1193
     */
1193
     */
1194
    public function test_update_event_start_day_activity_event_equal_to_max() {
1194
    public function test_update_event_start_day_activity_event_equal_to_max(): void {
1195
        global $CFG, $DB;
1195
        global $CFG, $DB;
1196
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1196
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1197... Línea 1197...
1197
 
1197
 
1198
        $this->resetAfterTest(true);
1198
        $this->resetAfterTest(true);
Línea 1225... Línea 1225...
1225
     * property. Instead it should throw an exception.
1225
     * property. Instead it should throw an exception.
1226
     *
1226
     *
1227
     * Note: This test uses the feedback activity because it requires
1227
     * Note: This test uses the feedback activity because it requires
1228
     * module callbacks to be in place to test.
1228
     * module callbacks to be in place to test.
1229
     */
1229
     */
1230
    public function test_update_event_start_day_activity_event_after_max() {
1230
    public function test_update_event_start_day_activity_event_after_max(): void {
1231
        global $CFG, $DB;
1231
        global $CFG, $DB;
1232
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1232
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1233... Línea 1233...
1233
 
1233
 
1234
        $this->resetAfterTest(true);
1234
        $this->resetAfterTest(true);
Línea 1256... Línea 1256...
1256
     * update the corresponding activity property.
1256
     * update the corresponding activity property.
1257
     *
1257
     *
1258
     * Note: This test uses the feedback activity because it requires
1258
     * Note: This test uses the feedback activity because it requires
1259
     * module callbacks to be in place to test.
1259
     * module callbacks to be in place to test.
1260
     */
1260
     */
1261
    public function test_update_event_start_day_activity_event_no_min() {
1261
    public function test_update_event_start_day_activity_event_no_min(): void {
1262
        global $CFG, $DB;
1262
        global $CFG, $DB;
1263
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1263
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1264... Línea 1264...
1264
 
1264
 
1265
        $this->resetAfterTest(true);
1265
        $this->resetAfterTest(true);
Línea 1292... Línea 1292...
1292
     * property.
1292
     * property.
1293
     *
1293
     *
1294
     * Note: This test uses the feedback activity because it requires
1294
     * Note: This test uses the feedback activity because it requires
1295
     * module callbacks to be in place to test.
1295
     * module callbacks to be in place to test.
1296
     */
1296
     */
1297
    public function test_update_event_start_day_activity_event_greater_than_min() {
1297
    public function test_update_event_start_day_activity_event_greater_than_min(): void {
1298
        global $CFG, $DB;
1298
        global $CFG, $DB;
1299
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1299
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1300... Línea 1300...
1300
 
1300
 
1301
        $this->resetAfterTest(true);
1301
        $this->resetAfterTest(true);
Línea 1329... Línea 1329...
1329
     * property.
1329
     * property.
1330
     *
1330
     *
1331
     * Note: This test uses the feedback activity because it requires
1331
     * Note: This test uses the feedback activity because it requires
1332
     * module callbacks to be in place to test.
1332
     * module callbacks to be in place to test.
1333
     */
1333
     */
1334
    public function test_update_event_start_day_activity_event_equal_to_min() {
1334
    public function test_update_event_start_day_activity_event_equal_to_min(): void {
1335
        global $CFG, $DB;
1335
        global $CFG, $DB;
1336
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1336
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1337... Línea 1337...
1337
 
1337
 
1338
        $this->resetAfterTest(true);
1338
        $this->resetAfterTest(true);
Línea 1366... Línea 1366...
1366
     * property. Instead it should throw an exception.
1366
     * property. Instead it should throw an exception.
1367
     *
1367
     *
1368
     * Note: This test uses the feedback activity because it requires
1368
     * Note: This test uses the feedback activity because it requires
1369
     * module callbacks to be in place to test.
1369
     * module callbacks to be in place to test.
1370
     */
1370
     */
1371
    public function test_update_event_start_day_activity_event_before_min() {
1371
    public function test_update_event_start_day_activity_event_before_min(): void {
1372
        global $CFG, $DB;
1372
        global $CFG, $DB;
1373
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
1373
        require_once($CFG->dirroot . '/mod/feedback/lib.php');
Línea 1374... Línea 1374...
1374
 
1374
 
1375
        $this->resetAfterTest(true);
1375
        $this->resetAfterTest(true);
Línea 1398... Línea 1398...
1398
     * of override events.
1398
     * of override events.
1399
     *
1399
     *
1400
     * Note: This test uses the quiz activity because it requires
1400
     * Note: This test uses the quiz activity because it requires
1401
     * module callbacks to be in place and override event support to test.
1401
     * module callbacks to be in place and override event support to test.
1402
     */
1402
     */
1403
    public function test_update_event_start_day_activity_event_override() {
1403
    public function test_update_event_start_day_activity_event_override(): void {
1404
        global $CFG, $DB;
1404
        global $CFG, $DB;
1405
        require_once($CFG->dirroot . '/calendar/lib.php');
1405
        require_once($CFG->dirroot . '/calendar/lib.php');
1406
        require_once($CFG->dirroot . '/mod/quiz/lib.php');
1406
        require_once($CFG->dirroot . '/mod/quiz/lib.php');
Línea 1407... Línea 1407...
1407
 
1407