Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 48... Línea 48...
48
final class externallib_test extends externallib_advanced_testcase {
48
final class externallib_test extends externallib_advanced_testcase {
Línea 49... Línea 49...
49
 
49
 
50
    /**
50
    /**
51
     * Test get_users
51
     * Test get_users
52
     */
52
     */
53
    public function test_get_users() {
53
    public function test_get_users(): void {
Línea 54... Línea 54...
54
        global $USER, $CFG;
54
        global $USER, $CFG;
Línea 55... Línea 55...
55
 
55
 
Línea 417... Línea 417...
417
    }
417
    }
Línea 418... Línea 418...
418
 
418
 
419
    /**
419
    /**
420
     * Test get_course_user_profiles
420
     * Test get_course_user_profiles
421
     */
421
     */
422
    public function test_get_course_user_profiles() {
422
    public function test_get_course_user_profiles(): void {
Línea 423... Línea 423...
423
        global $USER, $CFG;
423
        global $USER, $CFG;
Línea 424... Línea 424...
424
 
424
 
Línea 435... Línea 435...
435
 
435
 
436
        // Check we retrieve the good total number of enrolled users + no error on capability.
436
        // Check we retrieve the good total number of enrolled users + no error on capability.
437
        $this->assertEquals(1, count($enrolledusers));
437
        $this->assertEquals(1, count($enrolledusers));
Línea 438... Línea 438...
438
    }
438
    }
439
 
439
 
Línea 440... Línea 440...
440
    public function test_get_user_course_profile_as_admin() {
440
    public function test_get_user_course_profile_as_admin(): void {
Línea 441... Línea 441...
441
        global $USER, $CFG;
441
        global $USER, $CFG;
Línea 488... Línea 488...
488
    }
488
    }
Línea 489... Línea 489...
489
 
489
 
490
    /**
490
    /**
491
     * Test create_users
491
     * Test create_users
492
     */
492
     */
493
    public function test_create_users() {
493
    public function test_create_users(): void {
Línea 494... Línea 494...
494
        global $DB;
494
        global $DB;
Línea 495... Línea 495...
495
 
495
 
Línea 587... Línea 587...
587
    }
587
    }
Línea 588... Línea 588...
588
 
588
 
589
    /**
589
    /**
590
     * Test create_users with password and createpassword parameter not set.
590
     * Test create_users with password and createpassword parameter not set.
591
     */
591
     */
592
    public function test_create_users_empty_password() {
592
    public function test_create_users_empty_password(): void {
593
        $this->resetAfterTest();
593
        $this->resetAfterTest();
Línea 594... Línea 594...
594
        $this->setAdminUser();
594
        $this->setAdminUser();
595
 
595
 
Línea 630... Línea 630...
630
     *
630
     *
631
     * @dataProvider create_users_provider_with_same_emails
631
     * @dataProvider create_users_provider_with_same_emails
632
     * @param int $sameemailallowed The value to set for $CFG->allowaccountssameemail.
632
     * @param int $sameemailallowed The value to set for $CFG->allowaccountssameemail.
633
     * @param boolean $differentcase Whether to user a different case for the other user.
633
     * @param boolean $differentcase Whether to user a different case for the other user.
634
     */
634
     */
635
    public function test_create_users_with_same_emails($sameemailallowed, $differentcase) {
635
    public function test_create_users_with_same_emails($sameemailallowed, $differentcase): void {
636
        global $DB;
636
        global $DB;
Línea 637... Línea 637...
637
 
637
 
638
        $this->resetAfterTest();
638
        $this->resetAfterTest();
Línea 675... Línea 675...
675
     *
675
     *
676
     * @dataProvider data_create_users_invalid_parameter
676
     * @dataProvider data_create_users_invalid_parameter
677
     * @param array $data User data to attempt to register.
677
     * @param array $data User data to attempt to register.
678
     * @param string $expectmessage Expected exception message.
678
     * @param string $expectmessage Expected exception message.
679
     */
679
     */
680
    public function test_create_users_invalid_parameter(array $data, $expectmessage) {
680
    public function test_create_users_invalid_parameter(array $data, $expectmessage): void {
681
        global $USER, $CFG, $DB;
681
        global $USER, $CFG, $DB;
Línea 682... Línea 682...
682
 
682
 
683
        $this->resetAfterTest(true);
683
        $this->resetAfterTest(true);
Línea 749... Línea 749...
749
    }
749
    }
Línea 750... Línea 750...
750
 
750
 
751
    /**
751
    /**
752
     * Test delete_users
752
     * Test delete_users
753
     */
753
     */
754
    public function test_delete_users() {
754
    public function test_delete_users(): void {
Línea 755... Línea 755...
755
        global $USER, $CFG, $DB;
755
        global $USER, $CFG, $DB;
Línea 756... Línea 756...
756
 
756
 
Línea 780... Línea 780...
780
    }
780
    }
Línea 781... Línea 781...
781
 
781
 
782
    /**
782
    /**
783
     * Test update_users
783
     * Test update_users
784
     */
784
     */
785
    public function test_update_users() {
785
    public function test_update_users(): void {
Línea 786... Línea 786...
786
        global $USER, $CFG, $DB;
786
        global $USER, $CFG, $DB;
787
 
787
 
Línea 987... Línea 987...
987
     * @param string $newemail The user's new email.
987
     * @param string $newemail The user's new email.
988
     * @param boolean $withanotheruser Whether to create another user that has the same email as the target user's new email.
988
     * @param boolean $withanotheruser Whether to create another user that has the same email as the target user's new email.
989
     * @param boolean $successexpected Whether we expect that the target user's email/name will be updated.
989
     * @param boolean $successexpected Whether we expect that the target user's email/name will be updated.
990
     */
990
     */
991
    public function test_update_users_emails_with_different_cases($allowsameemail, $currentname, $currentemail,
991
    public function test_update_users_emails_with_different_cases($allowsameemail, $currentname, $currentemail,
992
                                                                  $newname, $newemail, $withanotheruser, $successexpected) {
992
                                                                  $newname, $newemail, $withanotheruser, $successexpected): void {
993
        global $DB;
993
        global $DB;
Línea 994... Línea 994...
994
 
994
 
995
        $this->resetAfterTest();
995
        $this->resetAfterTest();
Línea 1034... Línea 1034...
1034
    }
1034
    }
Línea 1035... Línea 1035...
1035
 
1035
 
1036
    /**
1036
    /**
1037
     * Test add_user_private_files
1037
     * Test add_user_private_files
1038
     */
1038
     */
1039
    public function test_add_user_private_files() {
1039
    public function test_add_user_private_files(): void {
Línea 1040... Línea 1040...
1040
        global $USER, $CFG, $DB;
1040
        global $USER, $CFG, $DB;
Línea 1041... Línea 1041...
1041
 
1041
 
Línea 1080... Línea 1080...
1080
 
1080
 
1081
 
1081
 
1082
    /**
1082
    /**
1083
     * Test add_user_private_files quota
1083
     * Test add_user_private_files quota
1084
     */
1084
     */
Línea 1085... Línea 1085...
1085
    public function test_add_user_private_files_quota() {
1085
    public function test_add_user_private_files_quota(): void {
Línea 1086... Línea 1086...
1086
        global $USER, $CFG, $DB;
1086
        global $USER, $CFG, $DB;
Línea 1128... Línea 1128...
1128
    }
1128
    }
Línea 1129... Línea 1129...
1129
 
1129
 
1130
    /**
1130
    /**
1131
     * Test add user device
1131
     * Test add user device
1132
     */
1132
     */
1133
    public function test_add_user_device() {
1133
    public function test_add_user_device(): void {
Línea 1134... Línea 1134...
1134
        global $USER, $CFG, $DB;
1134
        global $USER, $CFG, $DB;
Línea 1135... Línea 1135...
1135
 
1135
 
Línea 1183... Línea 1183...
1183
    }
1183
    }
Línea 1184... Línea 1184...
1184
 
1184
 
1185
    /**
1185
    /**
1186
     * Test remove user device
1186
     * Test remove user device
1187
     */
1187
     */
1188
    public function test_remove_user_device() {
1188
    public function test_remove_user_device(): void {
Línea 1189... Línea 1189...
1189
        global $USER, $CFG, $DB;
1189
        global $USER, $CFG, $DB;
Línea 1190... Línea 1190...
1190
 
1190
 
Línea 1238... Línea 1238...
1238
    }
1238
    }
Línea 1239... Línea 1239...
1239
 
1239
 
1240
    /**
1240
    /**
1241
     * Test get_user_preferences
1241
     * Test get_user_preferences
1242
     */
1242
     */
1243
    public function test_get_user_preferences() {
1243
    public function test_get_user_preferences(): void {
Línea 1244... Línea 1244...
1244
        $this->resetAfterTest(true);
1244
        $this->resetAfterTest(true);
1245
 
1245
 
1246
        $user = self::getDataGenerator()->create_user();
1246
        $user = self::getDataGenerator()->create_user();
Línea 1301... Línea 1301...
1301
    }
1301
    }
Línea 1302... Línea 1302...
1302
 
1302
 
1303
    /**
1303
    /**
1304
     * Test update_picture
1304
     * Test update_picture
1305
     */
1305
     */
1306
    public function test_update_picture() {
1306
    public function test_update_picture(): void {
Línea 1307... Línea 1307...
1307
        global $DB, $USER;
1307
        global $DB, $USER;
Línea 1308... Línea 1308...
1308
 
1308
 
Línea 1354... Línea 1354...
1354
    }
1354
    }
Línea 1355... Línea 1355...
1355
 
1355
 
1356
    /**
1356
    /**
1357
     * Test update_picture disabled
1357
     * Test update_picture disabled
1358
     */
1358
     */
1359
    public function test_update_picture_disabled() {
1359
    public function test_update_picture_disabled(): void {
1360
        global $CFG;
1360
        global $CFG;
1361
        $this->resetAfterTest(true);
1361
        $this->resetAfterTest(true);
Línea 1362... Línea 1362...
1362
        $CFG->disableuserimages = true;
1362
        $CFG->disableuserimages = true;
Línea 1367... Línea 1367...
1367
    }
1367
    }
Línea 1368... Línea 1368...
1368
 
1368
 
1369
    /**
1369
    /**
1370
     * Test set_user_preferences
1370
     * Test set_user_preferences
1371
     */
1371
     */
1372
    public function test_set_user_preferences_save() {
1372
    public function test_set_user_preferences_save(): void {
1373
        global $DB;
1373
        global $DB;
Línea 1374... Línea 1374...
1374
        $this->resetAfterTest(true);
1374
        $this->resetAfterTest(true);
1375
 
1375
 
Línea 1404... Línea 1404...
1404
    }
1404
    }
Línea 1405... Línea 1405...
1405
 
1405
 
1406
    /**
1406
    /**
1407
     * Test set_user_preferences
1407
     * Test set_user_preferences
1408
     */
1408
     */
1409
    public function test_set_user_preferences_save_invalid_pref() {
1409
    public function test_set_user_preferences_save_invalid_pref(): void {
1410
        global $DB;
1410
        global $DB;
Línea 1411... Línea 1411...
1411
        $this->resetAfterTest(true);
1411
        $this->resetAfterTest(true);
Línea 1433... Línea 1433...
1433
    }
1433
    }
Línea 1434... Línea 1434...
1434
 
1434
 
1435
    /**
1435
    /**
1436
     * Test set_user_preferences for an invalid user
1436
     * Test set_user_preferences for an invalid user
1437
     */
1437
     */
1438
    public function test_set_user_preferences_invalid_user() {
1438
    public function test_set_user_preferences_invalid_user(): void {
Línea 1439... Línea 1439...
1439
        $this->resetAfterTest(true);
1439
        $this->resetAfterTest(true);
1440
 
1440
 
1441
        $this->setAdminUser();
1441
        $this->setAdminUser();
Línea 1456... Línea 1456...
1456
    }
1456
    }
Línea 1457... Línea 1457...
1457
 
1457
 
1458
    /**
1458
    /**
1459
     * Test set_user_preferences using an invalid preference
1459
     * Test set_user_preferences using an invalid preference
1460
     */
1460
     */
1461
    public function test_set_user_preferences_invalid_preference() {
1461
    public function test_set_user_preferences_invalid_preference(): void {
Línea 1462... Línea 1462...
1462
        global $USER, $DB;
1462
        global $USER, $DB;
1463
 
1463
 
1464
        $this->resetAfterTest(true);
1464
        $this->resetAfterTest(true);
Línea 1482... Línea 1482...
1482
    }
1482
    }
Línea 1483... Línea 1483...
1483
 
1483
 
1484
    /**
1484
    /**
1485
     * Test set_user_preferences for other user not being admin
1485
     * Test set_user_preferences for other user not being admin
1486
     */
1486
     */
1487
    public function test_set_user_preferences_capability() {
1487
    public function test_set_user_preferences_capability(): void {
Línea 1488... Línea 1488...
1488
        $this->resetAfterTest(true);
1488
        $this->resetAfterTest(true);
1489
 
1489
 
Línea 1508... Línea 1508...
1508
    }
1508
    }
Línea 1509... Línea 1509...
1509
 
1509
 
1510
    /**
1510
    /**
1511
     * Test update_user_preferences unsetting an existing preference.
1511
     * Test update_user_preferences unsetting an existing preference.
1512
     */
1512
     */
1513
    public function test_update_user_preferences_unset() {
1513
    public function test_update_user_preferences_unset(): void {
1514
        global $DB;
1514
        global $DB;
Línea 1515... Línea 1515...
1515
        $this->resetAfterTest(true);
1515
        $this->resetAfterTest(true);
Línea 1542... Línea 1542...
1542
    }
1542
    }
Línea 1543... Línea 1543...
1543
 
1543
 
1544
    /**
1544
    /**
1545
     * Test agree_site_policy
1545
     * Test agree_site_policy
1546
     */
1546
     */
1547
    public function test_agree_site_policy() {
1547
    public function test_agree_site_policy(): void {
1548
        global $CFG, $DB, $USER;
1548
        global $CFG, $DB, $USER;
Línea 1549... Línea 1549...
1549
        $this->resetAfterTest(true);
1549
        $this->resetAfterTest(true);
1550
 
1550
 
Línea 1593... Línea 1593...
1593
    }
1593
    }
Línea 1594... Línea 1594...
1594
 
1594
 
1595
    /**
1595
    /**
1596
     * Test get_private_files_info
1596
     * Test get_private_files_info
1597
     */
1597
     */
Línea 1598... Línea 1598...
1598
    public function test_get_private_files_info() {
1598
    public function test_get_private_files_info(): void {
1599
 
1599
 
1600
        $this->resetAfterTest(true);
1600
        $this->resetAfterTest(true);
1601
        $user = self::getDataGenerator()->create_user();
1601
        $user = self::getDataGenerator()->create_user();
Línea 1633... Línea 1633...
1633
    }
1633
    }
Línea 1634... Línea 1634...
1634
 
1634
 
1635
    /**
1635
    /**
1636
     * Test get_private_files_info missing permissions.
1636
     * Test get_private_files_info missing permissions.
1637
     */
1637
     */
Línea 1638... Línea 1638...
1638
    public function test_get_private_files_info_missing_permissions() {
1638
    public function test_get_private_files_info_missing_permissions(): void {
1639
 
1639
 
1640
        $this->resetAfterTest(true);
1640
        $this->resetAfterTest(true);
1641
        $user1 = self::getDataGenerator()->create_user();
1641
        $user1 = self::getDataGenerator()->create_user();
Línea 1648... Línea 1648...
1648
    }
1648
    }
Línea 1649... Línea 1649...
1649
 
1649
 
1650
    /**
1650
    /**
1651
     * Test the functionality of the {@see \core_user\external\search_identity} class.
1651
     * Test the functionality of the {@see \core_user\external\search_identity} class.
1652
     */
1652
     */
1653
    public function test_external_search_identity() {
1653
    public function test_external_search_identity(): void {
Línea 1654... Línea 1654...
1654
        global $CFG;
1654
        global $CFG;
1655
 
1655
 
Línea 1757... Línea 1757...
1757
    }
1757
    }
Línea 1758... Línea 1758...
1758
 
1758
 
1759
    /**
1759
    /**
1760
     * Test functionality of the {@see \core_user\external\search_identity} class with alternativefullnameformat defined.
1760
     * Test functionality of the {@see \core_user\external\search_identity} class with alternativefullnameformat defined.
1761
     */
1761
     */
1762
    public function test_external_search_identity_with_alternativefullnameformat() {
1762
    public function test_external_search_identity_with_alternativefullnameformat(): void {
Línea 1763... Línea 1763...
1763
        global $CFG;
1763
        global $CFG;
1764
 
1764
 
Línea 1793... Línea 1793...
1793
    }
1793
    }
Línea 1794... Línea 1794...
1794
 
1794
 
1795
    /**
1795
    /**
1796
     * Test verifying that update_user_preferences prevents changes to the default homepage for other users.
1796
     * Test verifying that update_user_preferences prevents changes to the default homepage for other users.
1797
     */
1797
     */
1798
    public function test_update_user_preferences_homepage_permission_callback() {
1798
    public function test_update_user_preferences_homepage_permission_callback(): void {
1799
        global $DB;
1799
        global $DB;
Línea 1800... Línea 1800...
1800
        $this->resetAfterTest();
1800
        $this->resetAfterTest();
1801
 
1801