Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 40... Línea 40...
40
 */
40
 */
41
class lib_test extends \advanced_testcase {
41
class lib_test extends \advanced_testcase {
42
    /**
42
    /**
43
     * Test for lesson_get_group_override_priorities().
43
     * Test for lesson_get_group_override_priorities().
44
     */
44
     */
45
    public function test_lesson_get_group_override_priorities() {
45
    public function test_lesson_get_group_override_priorities(): void {
46
        global $DB;
46
        global $DB;
47
        $this->resetAfterTest();
47
        $this->resetAfterTest();
48
        $this->setAdminUser();
48
        $this->setAdminUser();
Línea 49... Línea 49...
49
 
49
 
Línea 88... Línea 88...
88
    }
88
    }
Línea 89... Línea 89...
89
 
89
 
90
    /**
90
    /**
91
     * Test check_updates_since callback.
91
     * Test check_updates_since callback.
92
     */
92
     */
93
    public function test_check_updates_since() {
93
    public function test_check_updates_since(): void {
Línea 94... Línea 94...
94
        global $DB;
94
        global $DB;
95
 
95
 
96
        $this->resetAfterTest();
96
        $this->resetAfterTest();
Línea 223... Línea 223...
223
 
223
 
224
        $this->assertTrue($updates->usertimers->updated);
224
        $this->assertTrue($updates->usertimers->updated);
225
        $this->assertCount(1, $updates->usertimers->itemids);
225
        $this->assertCount(1, $updates->usertimers->itemids);
Línea 226... Línea 226...
226
    }
226
    }
227
 
227
 
228
    public function test_lesson_core_calendar_provide_event_action_open() {
228
    public function test_lesson_core_calendar_provide_event_action_open(): void {
229
        $this->resetAfterTest();
229
        $this->resetAfterTest();
230
        $this->setAdminUser();
230
        $this->setAdminUser();
231
        // Create a course.
231
        // Create a course.
Línea 250... Línea 250...
250
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
250
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
251
        $this->assertEquals(1, $actionevent->get_item_count());
251
        $this->assertEquals(1, $actionevent->get_item_count());
252
        $this->assertTrue($actionevent->is_actionable());
252
        $this->assertTrue($actionevent->is_actionable());
253
    }
253
    }
Línea 254... Línea 254...
254
 
254
 
255
    public function test_lesson_core_calendar_provide_event_action_open_as_non_user() {
255
    public function test_lesson_core_calendar_provide_event_action_open_as_non_user(): void {
Línea 256... Línea 256...
256
        global $CFG;
256
        global $CFG;
257
 
257
 
Línea 280... Línea 280...
280
 
280
 
281
        // Confirm the event is not shown at all.
281
        // Confirm the event is not shown at all.
282
        $this->assertNull($actionevent);
282
        $this->assertNull($actionevent);
Línea 283... Línea 283...
283
    }
283
    }
284
 
284
 
Línea 285... Línea 285...
285
    public function test_lesson_core_calendar_provide_event_action_open_for_user() {
285
    public function test_lesson_core_calendar_provide_event_action_open_for_user(): void {
286
        global $CFG;
286
        global $CFG;
Línea 317... Línea 317...
317
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
317
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
318
        $this->assertEquals(1, $actionevent->get_item_count());
318
        $this->assertEquals(1, $actionevent->get_item_count());
319
        $this->assertTrue($actionevent->is_actionable());
319
        $this->assertTrue($actionevent->is_actionable());
320
    }
320
    }
Línea 321... Línea 321...
321
 
321
 
322
    public function test_lesson_core_calendar_provide_event_action_open_in_hidden_section() {
322
    public function test_lesson_core_calendar_provide_event_action_open_in_hidden_section(): void {
323
        $this->resetAfterTest();
323
        $this->resetAfterTest();
Línea 324... Línea 324...
324
        $this->setAdminUser();
324
        $this->setAdminUser();
325
 
325
 
Línea 347... Línea 347...
347
 
347
 
348
        // Confirm the event is not shown at all.
348
        // Confirm the event is not shown at all.
349
        $this->assertNull($actionevent);
349
        $this->assertNull($actionevent);
Línea 350... Línea 350...
350
    }
350
    }
351
 
351
 
352
    public function test_lesson_core_calendar_provide_event_action_closed() {
352
    public function test_lesson_core_calendar_provide_event_action_closed(): void {
Línea 353... Línea 353...
353
        $this->resetAfterTest();
353
        $this->resetAfterTest();
354
        $this->setAdminUser();
354
        $this->setAdminUser();
Línea 379... Línea 379...
379
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
379
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
380
        $this->assertEquals(1, $actionevent->get_item_count());
380
        $this->assertEquals(1, $actionevent->get_item_count());
381
        $this->assertFalse($actionevent->is_actionable());
381
        $this->assertFalse($actionevent->is_actionable());
382
    }
382
    }
Línea 383... Línea 383...
383
 
383
 
384
    public function test_lesson_core_calendar_provide_event_action_closed_for_user() {
384
    public function test_lesson_core_calendar_provide_event_action_closed_for_user(): void {
Línea 385... Línea 385...
385
        global $CFG;
385
        global $CFG;
386
 
386
 
Línea 416... Línea 416...
416
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
416
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
417
        $this->assertEquals(1, $actionevent->get_item_count());
417
        $this->assertEquals(1, $actionevent->get_item_count());
418
        $this->assertFalse($actionevent->is_actionable());
418
        $this->assertFalse($actionevent->is_actionable());
419
    }
419
    }
Línea 420... Línea 420...
420
 
420
 
421
    public function test_lesson_core_calendar_provide_event_action_open_in_future() {
421
    public function test_lesson_core_calendar_provide_event_action_open_in_future(): void {
422
        $this->resetAfterTest();
422
        $this->resetAfterTest();
Línea 423... Línea 423...
423
        $this->setAdminUser();
423
        $this->setAdminUser();
424
 
424
 
Línea 447... Línea 447...
447
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
447
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
448
        $this->assertEquals(1, $actionevent->get_item_count());
448
        $this->assertEquals(1, $actionevent->get_item_count());
449
        $this->assertFalse($actionevent->is_actionable());
449
        $this->assertFalse($actionevent->is_actionable());
450
    }
450
    }
Línea 451... Línea 451...
451
 
451
 
452
    public function test_lesson_core_calendar_provide_event_action_open_in_future_for_user() {
452
    public function test_lesson_core_calendar_provide_event_action_open_in_future_for_user(): void {
Línea 453... Línea 453...
453
        global $CFG;
453
        global $CFG;
454
 
454
 
Línea 484... Línea 484...
484
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
484
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
485
        $this->assertEquals(1, $actionevent->get_item_count());
485
        $this->assertEquals(1, $actionevent->get_item_count());
486
        $this->assertFalse($actionevent->is_actionable());
486
        $this->assertFalse($actionevent->is_actionable());
487
    }
487
    }
Línea 488... Línea 488...
488
 
488
 
489
    public function test_lesson_core_calendar_provide_event_action_no_time_specified() {
489
    public function test_lesson_core_calendar_provide_event_action_no_time_specified(): void {
490
        $this->resetAfterTest();
490
        $this->resetAfterTest();
Línea 491... Línea 491...
491
        $this->setAdminUser();
491
        $this->setAdminUser();
492
 
492
 
Línea 513... Línea 513...
513
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
513
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
514
        $this->assertEquals(1, $actionevent->get_item_count());
514
        $this->assertEquals(1, $actionevent->get_item_count());
515
        $this->assertTrue($actionevent->is_actionable());
515
        $this->assertTrue($actionevent->is_actionable());
516
    }
516
    }
Línea 517... Línea 517...
517
 
517
 
518
    public function test_lesson_core_calendar_provide_event_action_no_time_specified_for_user() {
518
    public function test_lesson_core_calendar_provide_event_action_no_time_specified_for_user(): void {
Línea 519... Línea 519...
519
        global $CFG;
519
        global $CFG;
520
 
520
 
Línea 549... Línea 549...
549
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
549
        $this->assertInstanceOf('moodle_url', $actionevent->get_url());
550
        $this->assertEquals(1, $actionevent->get_item_count());
550
        $this->assertEquals(1, $actionevent->get_item_count());
551
        $this->assertTrue($actionevent->is_actionable());
551
        $this->assertTrue($actionevent->is_actionable());
552
    }
552
    }
Línea 553... Línea 553...
553
 
553
 
554
    public function test_lesson_core_calendar_provide_event_action_after_attempt() {
554
    public function test_lesson_core_calendar_provide_event_action_after_attempt(): void {
Línea 555... Línea 555...
555
        global $DB;
555
        global $DB;
556
 
556
 
Línea 599... Línea 599...
599
 
599
 
600
        // Confirm there was no action for the user.
600
        // Confirm there was no action for the user.
601
        $this->assertNull($action);
601
        $this->assertNull($action);
Línea 602... Línea 602...
602
    }
602
    }
603
 
603
 
Línea 604... Línea 604...
604
    public function test_lesson_core_calendar_provide_event_action_after_attempt_for_user() {
604
    public function test_lesson_core_calendar_provide_event_action_after_attempt_for_user(): void {
605
        global $DB;
605
        global $DB;
Línea 650... Línea 650...
650
 
650
 
651
        // Confirm there was no action for the user.
651
        // Confirm there was no action for the user.
652
        $this->assertNull($action);
652
        $this->assertNull($action);
Línea 653... Línea 653...
653
    }
653
    }
654
 
654
 
655
    public function test_lesson_core_calendar_provide_event_action_already_completed() {
655
    public function test_lesson_core_calendar_provide_event_action_already_completed(): void {
656
        $this->resetAfterTest();
656
        $this->resetAfterTest();
Línea 657... Línea 657...
657
        set_config('enablecompletion', 1);
657
        set_config('enablecompletion', 1);
Línea 681... Línea 681...
681
 
681
 
682
        // Ensure result was null.
682
        // Ensure result was null.
683
        $this->assertNull($actionevent);
683
        $this->assertNull($actionevent);
Línea 684... Línea 684...
684
    }
684
    }
685
 
685
 
686
    public function test_lesson_core_calendar_provide_event_action_already_completed_for_user() {
686
    public function test_lesson_core_calendar_provide_event_action_already_completed_for_user(): void {
687
        $this->resetAfterTest();
687
        $this->resetAfterTest();
Línea 688... Línea 688...
688
        set_config('enablecompletion', 1);
688
        set_config('enablecompletion', 1);
Línea 740... Línea 740...
740
    /**
740
    /**
741
     * Test the callback responsible for returning the completion rule descriptions.
741
     * Test the callback responsible for returning the completion rule descriptions.
742
     * This function should work given either an instance of the module (cm_info), such as when checking the active rules,
742
     * This function should work given either an instance of the module (cm_info), such as when checking the active rules,
743
     * or if passed a stdClass of similar structure, such as when checking the the default completion settings for a mod type.
743
     * or if passed a stdClass of similar structure, such as when checking the the default completion settings for a mod type.
744
     */
744
     */
745
    public function test_mod_lesson_completion_get_active_rule_descriptions() {
745
    public function test_mod_lesson_completion_get_active_rule_descriptions(): void {
746
        $this->resetAfterTest();
746
        $this->resetAfterTest();
747
        $this->setAdminUser();
747
        $this->setAdminUser();
Línea 748... Línea 748...
748
 
748
 
749
        // Two activities, both with automatic completion. One has the 'completionsubmit' rule, one doesn't.
749
        // Two activities, both with automatic completion. One has the 'completionsubmit' rule, one doesn't.
Línea 784... Línea 784...
784
    }
784
    }
Línea 785... Línea 785...
785
 
785
 
786
    /**
786
    /**
787
     * An unknown event type should not change the lesson instance.
787
     * An unknown event type should not change the lesson instance.
788
     */
788
     */
789
    public function test_mod_lesson_core_calendar_event_timestart_updated_unknown_event() {
789
    public function test_mod_lesson_core_calendar_event_timestart_updated_unknown_event(): void {
790
        global $CFG, $DB;
790
        global $CFG, $DB;
Línea 791... Línea 791...
791
        require_once($CFG->dirroot . "/calendar/lib.php");
791
        require_once($CFG->dirroot . "/calendar/lib.php");
792
 
792
 
Línea 825... Línea 825...
825
    }
825
    }
Línea 826... Línea 826...
826
 
826
 
827
    /**
827
    /**
828
     * A LESSON_EVENT_TYPE_OPEN event should update the available property of the lesson activity.
828
     * A LESSON_EVENT_TYPE_OPEN event should update the available property of the lesson activity.
829
     */
829
     */
830
    public function test_mod_lesson_core_calendar_event_timestart_updated_open_event() {
830
    public function test_mod_lesson_core_calendar_event_timestart_updated_open_event(): void {
831
        global $CFG, $DB;
831
        global $CFG, $DB;
Línea 832... Línea 832...
832
        require_once($CFG->dirroot . "/calendar/lib.php");
832
        require_once($CFG->dirroot . "/calendar/lib.php");
833
 
833
 
Línea 885... Línea 885...
885
    }
885
    }
Línea 886... Línea 886...
886
 
886
 
887
    /**
887
    /**
888
     * A LESSON_EVENT_TYPE_CLOSE event should update the deadline property of the lesson activity.
888
     * A LESSON_EVENT_TYPE_CLOSE event should update the deadline property of the lesson activity.
889
     */
889
     */
890
    public function test_mod_lesson_core_calendar_event_timestart_updated_close_event() {
890
    public function test_mod_lesson_core_calendar_event_timestart_updated_close_event(): void {
891
        global $CFG, $DB;
891
        global $CFG, $DB;
892
        require_once($CFG->dirroot . "/calendar/lib.php");
892
        require_once($CFG->dirroot . "/calendar/lib.php");
893
        $this->resetAfterTest(true);
893
        $this->resetAfterTest(true);
894
        $this->setAdminUser();
894
        $this->setAdminUser();
Línea 938... Línea 938...
938
    }
938
    }
Línea 939... Línea 939...
939
 
939
 
940
    /**
940
    /**
941
     * An unknown event type should not have any limits.
941
     * An unknown event type should not have any limits.
942
     */
942
     */
943
    public function test_mod_lesson_core_calendar_get_valid_event_timestart_range_unknown_event() {
943
    public function test_mod_lesson_core_calendar_get_valid_event_timestart_range_unknown_event(): void {
944
        global $CFG;
944
        global $CFG;
Línea 945... Línea 945...
945
        require_once($CFG->dirroot . "/calendar/lib.php");
945
        require_once($CFG->dirroot . "/calendar/lib.php");
946
 
946
 
Línea 976... Línea 976...
976
    }
976
    }
Línea 977... Línea 977...
977
 
977
 
978
    /**
978
    /**
979
     * The open event should be limited by the lesson's deadline property, if it's set.
979
     * The open event should be limited by the lesson's deadline property, if it's set.
980
     */
980
     */
981
    public function test_mod_lesson_core_calendar_get_valid_event_timestart_range_open_event() {
981
    public function test_mod_lesson_core_calendar_get_valid_event_timestart_range_open_event(): void {
982
        global $CFG;
982
        global $CFG;
Línea 983... Línea 983...
983
        require_once($CFG->dirroot . "/calendar/lib.php");
983
        require_once($CFG->dirroot . "/calendar/lib.php");
984
 
984
 
Línea 1021... Línea 1021...
1021
    }
1021
    }
Línea 1022... Línea 1022...
1022
 
1022
 
1023
    /**
1023
    /**
1024
     * The close event should be limited by the lesson's available property, if it's set.
1024
     * The close event should be limited by the lesson's available property, if it's set.
1025
     */
1025
     */
1026
    public function test_mod_lesson_core_calendar_get_valid_event_timestart_range_close_event() {
1026
    public function test_mod_lesson_core_calendar_get_valid_event_timestart_range_close_event(): void {
1027
        global $CFG;
1027
        global $CFG;
Línea 1028... Línea 1028...
1028
        require_once($CFG->dirroot . "/calendar/lib.php");
1028
        require_once($CFG->dirroot . "/calendar/lib.php");
1029
 
1029
 
Línea 1066... Línea 1066...
1066
    }
1066
    }
Línea 1067... Línea 1067...
1067
 
1067
 
1068
    /**
1068
    /**
1069
     * A user who does not have capabilities to add events to the calendar should be able to create an lesson.
1069
     * A user who does not have capabilities to add events to the calendar should be able to create an lesson.
1070
     */
1070
     */
1071
    public function test_creation_with_no_calendar_capabilities() {
1071
    public function test_creation_with_no_calendar_capabilities(): void {
1072
        $this->resetAfterTest();
1072
        $this->resetAfterTest();
1073
        $course = self::getDataGenerator()->create_course();
1073
        $course = self::getDataGenerator()->create_course();
1074
        $context = \context_course::instance($course->id);
1074
        $context = \context_course::instance($course->id);
1075
        $user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
1075
        $user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');