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 enrol migration function used when uninstalling enrol plugins.
43
     * Test enrol migration function used when uninstalling enrol plugins.
44
     */
44
     */
45
    public function test_migrate_plugin_enrolments() {
45
    public function test_migrate_plugin_enrolments(): void {
46
        global $DB, $CFG;
46
        global $DB, $CFG;
47
        require_once($CFG->dirroot.'/enrol/manual/locallib.php');
47
        require_once($CFG->dirroot.'/enrol/manual/locallib.php');
Línea 48... Línea 48...
48
 
48
 
Línea 205... Línea 205...
205
 
205
 
206
        enrol_manual_migrate_plugin_enrolments('manual');
206
        enrol_manual_migrate_plugin_enrolments('manual');
207
        enrol_manual_migrate_plugin_enrolments('yyyy');
207
        enrol_manual_migrate_plugin_enrolments('yyyy');
Línea 208... Línea 208...
208
    }
208
    }
209
 
209
 
210
    public function test_expired() {
210
    public function test_expired(): void {
Línea 211... Línea 211...
211
        global $DB;
211
        global $DB;
212
        $this->resetAfterTest();
212
        $this->resetAfterTest();
Línea 332... Línea 332...
332
        $this->assertEquals(1, $DB->count_records('role_assignments', array('roleid'=>$teacherrole->id)));
332
        $this->assertEquals(1, $DB->count_records('role_assignments', array('roleid'=>$teacherrole->id)));
333
        $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$maninstance1->id, 'userid'=>$user3->id, 'status'=>ENROL_USER_SUSPENDED)));
333
        $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$maninstance1->id, 'userid'=>$user3->id, 'status'=>ENROL_USER_SUSPENDED)));
334
        $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$maninstance2->id, 'userid'=>$user3->id, 'status'=>ENROL_USER_SUSPENDED)));
334
        $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$maninstance2->id, 'userid'=>$user3->id, 'status'=>ENROL_USER_SUSPENDED)));
335
    }
335
    }
Línea 336... Línea 336...
336
 
336
 
337
    public function test_send_expiry_notifications() {
337
    public function test_send_expiry_notifications(): void {
338
        global $DB, $CFG;
338
        global $DB, $CFG;
339
        $this->resetAfterTest();
339
        $this->resetAfterTest();
Línea 340... Línea 340...
340
        $this->preventResetByRollback(); // Messaging does not like transactions...
340
        $this->preventResetByRollback(); // Messaging does not like transactions...
Línea 499... Línea 499...
499
    }
499
    }
Línea 500... Línea 500...
500
 
500
 
501
    /**
501
    /**
502
     * Test for getting user enrolment actions.
502
     * Test for getting user enrolment actions.
503
     */
503
     */
504
    public function test_get_user_enrolment_actions() {
504
    public function test_get_user_enrolment_actions(): void {
505
        global $CFG, $PAGE;
505
        global $CFG, $PAGE;
Línea 506... Línea 506...
506
        $this->resetAfterTest();
506
        $this->resetAfterTest();
507
 
507
 
Línea 551... Línea 551...
551
     * @dataProvider default_enrolment_instance_data_provider
551
     * @dataProvider default_enrolment_instance_data_provider
552
     * @param stdClass $expectation
552
     * @param stdClass $expectation
553
     * @param stdClass $globalsettings
553
     * @param stdClass $globalsettings
554
     * @covers \enrol_manual::add_default_instance
554
     * @covers \enrol_manual::add_default_instance
555
     */
555
     */
556
    public function test_default_enrolment_instance_acquires_correct_settings(stdClass $expectation, stdClass $globalsettings) {
556
    public function test_default_enrolment_instance_acquires_correct_settings(stdClass $expectation, stdClass $globalsettings): void {
557
        global $DB;
557
        global $DB;
Línea 558... Línea 558...
558
 
558
 
Línea 559... Línea 559...
559
        $this->resetAfterTest();
559
        $this->resetAfterTest();
Línea 765... Línea 765...
765
    /**
765
    /**
766
     * Test the behaviour of find_instance().
766
     * Test the behaviour of find_instance().
767
     *
767
     *
768
     * @covers ::find_instance
768
     * @covers ::find_instance
769
     */
769
     */
770
    public function test_find_instance() {
770
    public function test_find_instance(): void {
771
        global $DB;
771
        global $DB;
772
        $this->resetAfterTest();
772
        $this->resetAfterTest();
Línea 773... Línea 773...
773
 
773
 
774
        $cat = $this->getDataGenerator()->create_category();
774
        $cat = $this->getDataGenerator()->create_category();
Línea 798... Línea 798...
798
        global $DB;
798
        global $DB;
799
        $this->resetAfterTest();
799
        $this->resetAfterTest();
Línea 800... Línea 800...
800
 
800
 
801
        // Create course.
801
        // Create course.
802
        $course = $this->getDataGenerator()->create_course([
802
        $course = $this->getDataGenerator()->create_course([
803
            'fullname' => 'Course 1',
803
            'fullname' => 'Course 1 & 2',
804
            'shortname' => 'C1',
804
            'shortname' => 'C1',
805
        ]);
805
        ]);
806
        // Create users.
806
        // Create users.
807
        $student = $this->getDataGenerator()->create_user();
807
        $student = $this->getDataGenerator()->create_user();
Línea 858... Línea 858...
858
        $messagesink = $this->redirectMessages();
858
        $messagesink = $this->redirectMessages();
859
        $manualplugin->send_course_welcome_message_to_user(
859
        $manualplugin->send_course_welcome_message_to_user(
860
            instance: $maninstance,
860
            instance: $maninstance,
861
            userid: $student->id,
861
            userid: $student->id,
862
            sendoption: ENROL_SEND_EMAIL_FROM_COURSE_CONTACT,
862
            sendoption: ENROL_SEND_EMAIL_FROM_COURSE_CONTACT,
863
            message: 'Your email address: {$a->email}, your first name: {$a->firstname}, your last name: {$a->lastname}',
863
            message: 'Your email address: {$a->email}, your first name: {$a->firstname}, your last name: {$a->lastname}, ' .
-
 
864
                'your course: {$a->coursename}',
864
        );
865
        );
865
        $messages = $messagesink->get_messages_by_component_and_type(
866
        $messages = $messagesink->get_messages_by_component_and_type(
866
            'moodle',
867
            'moodle',
867
            'enrolcoursewelcomemessage',
868
            'enrolcoursewelcomemessage',
868
        );
869
        );
Línea 872... Línea 873...
872
        // The message should be sent from the second teacher.
873
        // The message should be sent from the second teacher.
873
        $this->assertEquals($teacher2->id, $message->useridfrom);
874
        $this->assertEquals($teacher2->id, $message->useridfrom);
874
        $this->assertStringContainsString($course->fullname, $message->subject);
875
        $this->assertStringContainsString($course->fullname, $message->subject);
875
        $this->assertEquals(
876
        $this->assertEquals(
876
            'Your email address: ' . $student->email . ', your first name: ' . $student->firstname . ', your last name: ' .
877
            'Your email address: ' . $student->email . ', your first name: ' . $student->firstname . ', your last name: ' .
877
                $student->lastname,
878
                $student->lastname . ', your course: ' . $course->fullname,
878
            $message->fullmessage,
879
            $message->fullmessage,
879
        );
880
        );
880
        // Clear sink.
881
        // Clear sink.
881
        $messagesink->clear();
882
        $messagesink->clear();