Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 34... Línea 34...
34
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 * @coversDefaultClass \enrol_self_plugin
35
 * @coversDefaultClass \enrol_self_plugin
36
 */
36
 */
37
class self_test extends \advanced_testcase {
37
class self_test extends \advanced_testcase {
Línea 38... Línea 38...
38
 
38
 
39
    public function test_basics() {
39
    public function test_basics(): void {
40
        $this->assertTrue(enrol_is_enabled('self'));
40
        $this->assertTrue(enrol_is_enabled('self'));
41
        $plugin = enrol_get_plugin('self');
41
        $plugin = enrol_get_plugin('self');
42
        $this->assertInstanceOf('enrol_self_plugin', $plugin);
42
        $this->assertInstanceOf('enrol_self_plugin', $plugin);
43
        $this->assertEquals(1, get_config('enrol_self', 'defaultenrol'));
43
        $this->assertEquals(1, get_config('enrol_self', 'defaultenrol'));
44
        $this->assertEquals(ENROL_EXT_REMOVED_KEEP, get_config('enrol_self', 'expiredaction'));
44
        $this->assertEquals(ENROL_EXT_REMOVED_KEEP, get_config('enrol_self', 'expiredaction'));
Línea 45... Línea 45...
45
    }
45
    }
46
 
46
 
Línea 47... Línea 47...
47
    public function test_sync_nothing() {
47
    public function test_sync_nothing(): void {
Línea 48... Línea 48...
48
        global $SITE;
48
        global $SITE;
Línea 54... Línea 54...
54
        // Just make sure the sync does not throw any errors when nothing to do.
54
        // Just make sure the sync does not throw any errors when nothing to do.
55
        $selfplugin->sync($trace, null);
55
        $selfplugin->sync($trace, null);
56
        $selfplugin->sync($trace, $SITE->id);
56
        $selfplugin->sync($trace, $SITE->id);
57
    }
57
    }
Línea 58... Línea 58...
58
 
58
 
59
    public function test_longtimnosee() {
59
    public function test_longtimnosee(): void {
60
        global $DB;
60
        global $DB;
Línea 61... Línea 61...
61
        $this->resetAfterTest();
61
        $this->resetAfterTest();
62
 
62
 
Línea 314... Línea 314...
314
        $selfplugin->set_config('expirynotifyhour', null);
314
        $selfplugin->set_config('expirynotifyhour', null);
315
        $selfplugin->send_expiry_notifications($trace);
315
        $selfplugin->send_expiry_notifications($trace);
316
        $this->assertDebuggingCalled('send_expiry_notifications() in self enrolment plugin needs expirynotifyhour setting');
316
        $this->assertDebuggingCalled('send_expiry_notifications() in self enrolment plugin needs expirynotifyhour setting');
317
    }
317
    }
Línea 318... Línea 318...
318
 
318
 
319
    public function test_expired() {
319
    public function test_expired(): void {
320
        global $DB;
320
        global $DB;
Línea 321... Línea 321...
321
        $this->resetAfterTest();
321
        $this->resetAfterTest();
322
 
322
 
Línea 431... Línea 431...
431
        $this->assertEquals(6, $DB->count_records('role_assignments'));
431
        $this->assertEquals(6, $DB->count_records('role_assignments'));
432
        $this->assertEquals(5, $DB->count_records('role_assignments', array('roleid'=>$studentrole->id)));
432
        $this->assertEquals(5, $DB->count_records('role_assignments', array('roleid'=>$studentrole->id)));
433
        $this->assertEquals(1, $DB->count_records('role_assignments', array('roleid'=>$teacherrole->id)));
433
        $this->assertEquals(1, $DB->count_records('role_assignments', array('roleid'=>$teacherrole->id)));
434
    }
434
    }
Línea 435... Línea 435...
435
 
435
 
436
    public function test_send_expiry_notifications() {
436
    public function test_send_expiry_notifications(): void {
437
        global $DB, $CFG;
437
        global $DB, $CFG;
438
        $this->resetAfterTest();
438
        $this->resetAfterTest();
Línea 439... Línea 439...
439
        $this->preventResetByRollback(); // Messaging does not like transactions...
439
        $this->preventResetByRollback(); // Messaging does not like transactions...
Línea 606... Línea 606...
606
        $selfplugin->set_config('expirynotifyhour', '0');
606
        $selfplugin->set_config('expirynotifyhour', '0');
607
        $selfplugin->send_expiry_notifications($trace);
607
        $selfplugin->send_expiry_notifications($trace);
608
        $this->assertEquals(6, $sink->count());
608
        $this->assertEquals(6, $sink->count());
609
    }
609
    }
Línea 610... Línea 610...
610
 
610
 
611
    public function test_show_enrolme_link() {
611
    public function test_show_enrolme_link(): void {
612
        global $DB, $CFG;
612
        global $DB, $CFG;
613
        $this->resetAfterTest();
613
        $this->resetAfterTest();
Línea 614... Línea 614...
614
        $this->preventResetByRollback(); // Messaging does not like transactions...
614
        $this->preventResetByRollback(); // Messaging does not like transactions...
Línea 738... Línea 738...
738
    }
738
    }
Línea 739... Línea 739...
739
 
739
 
740
    /**
740
    /**
741
     * This will check user enrolment only, rest has been tested in test_show_enrolme_link.
741
     * This will check user enrolment only, rest has been tested in test_show_enrolme_link.
742
     */
742
     */
743
    public function test_can_self_enrol() {
743
    public function test_can_self_enrol(): void {
744
        global $DB, $CFG, $OUTPUT;
744
        global $DB, $CFG, $OUTPUT;
745
        $this->resetAfterTest();
745
        $this->resetAfterTest();
Línea 746... Línea 746...
746
        $this->preventResetByRollback();
746
        $this->preventResetByRollback();
Línea 783... Línea 783...
783
    /**
783
    /**
784
     * Test is_self_enrol_available function behavior.
784
     * Test is_self_enrol_available function behavior.
785
     *
785
     *
786
     * @covers ::is_self_enrol_available
786
     * @covers ::is_self_enrol_available
787
     */
787
     */
788
    public function test_is_self_enrol_available() {
788
    public function test_is_self_enrol_available(): void {
789
        global $DB, $CFG;
789
        global $DB, $CFG;
Línea 790... Línea 790...
790
 
790
 
791
        $this->resetAfterTest();
791
        $this->resetAfterTest();
Línea 950... Línea 950...
950
    }
950
    }
Línea 951... Línea 951...
951
 
951
 
952
    /**
952
    /**
953
     * Test enrol_self_check_group_enrolment_key
953
     * Test enrol_self_check_group_enrolment_key
954
     */
954
     */
955
    public function test_enrol_self_check_group_enrolment_key() {
955
    public function test_enrol_self_check_group_enrolment_key(): void {
956
        global $DB;
956
        global $DB;
Línea 957... Línea 957...
957
        self::resetAfterTest(true);
957
        self::resetAfterTest(true);
958
 
958
 
Línea 987... Línea 987...
987
    }
987
    }
Línea 988... Línea 988...
988
 
988
 
989
    /**
989
    /**
990
     * Test get_welcome_email_contact().
990
     * Test get_welcome_email_contact().
991
     */
991
     */
992
    public function test_get_welcome_email_contact() {
992
    public function test_get_welcome_email_contact(): void {
993
        global $DB;
993
        global $DB;
Línea 994... Línea 994...
994
        self::resetAfterTest(true);
994
        self::resetAfterTest(true);
995
 
995
 
Línea 1070... Línea 1070...
1070
    }
1070
    }
Línea 1071... Línea 1071...
1071
 
1071
 
1072
    /**
1072
    /**
1073
     * Test for getting user enrolment actions.
1073
     * Test for getting user enrolment actions.
1074
     */
1074
     */
1075
    public function test_get_user_enrolment_actions() {
1075
    public function test_get_user_enrolment_actions(): void {
1076
        global $CFG, $DB, $PAGE;
1076
        global $CFG, $DB, $PAGE;
Línea 1077... Línea 1077...
1077
        $this->resetAfterTest();
1077
        $this->resetAfterTest();
1078
 
1078
 
Línea 1119... Línea 1119...
1119
    /**
1119
    /**
1120
     * Test the behaviour of find_instance().
1120
     * Test the behaviour of find_instance().
1121
     *
1121
     *
1122
     * @covers ::find_instance
1122
     * @covers ::find_instance
1123
     */
1123
     */
1124
    public function test_find_instance() {
1124
    public function test_find_instance(): void {
1125
        global $DB;
1125
        global $DB;
1126
        $this->resetAfterTest();
1126
        $this->resetAfterTest();
Línea 1127... Línea 1127...
1127
 
1127
 
1128
        $cat = $this->getDataGenerator()->create_category();
1128
        $cat = $this->getDataGenerator()->create_category();