Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 36... Línea 36...
36
 * @category   external
36
 * @category   external
37
 * @copyright  2012 Jerome Mouneyrac
37
 * @copyright  2012 Jerome Mouneyrac
38
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
 * @since Moodle 2.4
39
 * @since Moodle 2.4
40
 */
40
 */
41
class externallib_test extends externallib_advanced_testcase {
41
final class externallib_test extends externallib_advanced_testcase {
Línea 42... Línea 42...
42
 
42
 
43
    /**
43
    /**
44
     * dataProvider for test_get_enrolled_users_visibility().
44
     * dataProvider for test_get_enrolled_users_visibility().
45
     */
45
     */
46
    public function get_enrolled_users_visibility_provider() {
46
    public static function get_enrolled_users_visibility_provider(): array {
47
        return array(
47
        return array(
48
            'Course without groups, default behavior (not filtering by cap, group, active)' =>
48
            'Course without groups, default behavior (not filtering by cap, group, active)' =>
49
            array(
49
            array(
50
                'settings' => array(
50
                'settings' => array(
Línea 230... Línea 230...
230
                    'user2' => array('canview' => array()),
230
                    'user2' => array('canview' => array()),
231
                    'userall' => array('canview' => array()),
231
                    'userall' => array('canview' => array()),
232
                ),
232
                ),
233
            ),
233
            ),
Línea 234... Línea 234...
234
 
234
 
235
            'Course with separate groups, filtering by withcapability (having moodle/role:review)' =>
235
            'Course with separate groups, filtering by withcapability (having moodle/role:review & moodle/course:bulkmessaging)' =>
236
            array(
236
            array(
237
                'settings' => array(
237
                'settings' => array(
238
                    'coursegroupmode' => SEPARATEGROUPS,
238
                    'coursegroupmode' => SEPARATEGROUPS,
239
                    'withcapability' => 'moodle/course:bulkmessaging',
239
                    'withcapability' => 'moodle/course:bulkmessaging',
Línea 254... Línea 254...
254
    /**
254
    /**
255
     * Verify get_enrolled_users() returned users are the expected in every situation.
255
     * Verify get_enrolled_users() returned users are the expected in every situation.
256
     *
256
     *
257
     * @dataProvider get_enrolled_users_visibility_provider
257
     * @dataProvider get_enrolled_users_visibility_provider
258
     */
258
     */
259
    public function test_get_enrolled_users_visibility($settings, $results) {
259
    public function test_get_enrolled_users_visibility($settings, $results): void {
Línea 260... Línea 260...
260
 
260
 
Línea 261... Línea 261...
261
        global $USER;
261
        global $USER;
Línea 365... Línea 365...
365
    }
365
    }
Línea 366... Línea 366...
366
 
366
 
367
    /**
367
    /**
368
     * Verify get_enrolled_users() returned users according to their status.
368
     * Verify get_enrolled_users() returned users according to their status.
369
     */
369
     */
370
    public function test_get_enrolled_users_active_suspended() {
370
    public function test_get_enrolled_users_active_suspended(): void {
Línea 371... Línea 371...
371
        global $USER;
371
        global $USER;
Línea 372... Línea 372...
372
 
372
 
Línea 454... Línea 454...
454
    }
454
    }
Línea 455... Línea 455...
455
 
455
 
456
    /**
456
    /**
457
     * Test get_users_courses
457
     * Test get_users_courses
458
     */
458
     */
459
    public function test_get_users_courses() {
459
    public function test_get_users_courses(): void {
460
        global $CFG, $DB;
460
        global $CFG, $DB;
Línea 461... Línea 461...
461
        require_once($CFG->dirroot . '/completion/criteria/completion_criteria_self.php');
461
        require_once($CFG->dirroot . '/completion/criteria/completion_criteria_self.php');
462
 
462
 
Línea 709... Línea 709...
709
    }
709
    }
Línea 710... Línea 710...
710
 
710
 
711
    /**
711
    /**
712
     * Test get_users_courses with mathjax in the name.
712
     * Test get_users_courses with mathjax in the name.
713
     */
713
     */
714
    public function test_get_users_courses_with_mathjax() {
714
    public function test_get_users_courses_with_mathjax(): void {
Línea 715... Línea 715...
715
        global $DB;
715
        global $DB;
Línea 716... Línea 716...
716
 
716
 
Línea 770... Línea 770...
770
    }
770
    }
Línea 771... Línea 771...
771
 
771
 
772
    /**
772
    /**
773
     * Test get_course_enrolment_methods
773
     * Test get_course_enrolment_methods
774
     */
774
     */
775
    public function test_get_course_enrolment_methods() {
775
    public function test_get_course_enrolment_methods(): void {
Línea 776... Línea 776...
776
        global $DB;
776
        global $DB;
Línea 777... Línea 777...
777
 
777
 
Línea 876... Línea 876...
876
 
876
 
877
    /**
877
    /**
878
     * Test get_enrolled_users from core_enrol_external without additional
878
     * Test get_enrolled_users from core_enrol_external without additional
879
     * parameters.
879
     * parameters.
880
     */
880
     */
881
    public function test_get_enrolled_users_without_parameters() {
881
    public function test_get_enrolled_users_without_parameters(): void {
882
        $capability = 'moodle/course:viewparticipants';
882
        $capability = 'moodle/course:viewparticipants';
Línea 883... Línea 883...
883
        $data = $this->get_enrolled_users_setup($capability);
883
        $data = $this->get_enrolled_users_setup($capability);
884
 
884
 
Línea 894... Línea 894...
894
    }
894
    }
Línea 895... Línea 895...
895
 
895
 
896
    /**
896
    /**
897
     * Test get_enrolled_users from core_enrol_external with some parameters set.
897
     * Test get_enrolled_users from core_enrol_external with some parameters set.
898
     */
898
     */
899
    public function test_get_enrolled_users_with_parameters() {
899
    public function test_get_enrolled_users_with_parameters(): void {
900
        $capability = 'moodle/course:viewparticipants';
900
        $capability = 'moodle/course:viewparticipants';
Línea 901... Línea 901...
901
        $data = $this->get_enrolled_users_setup($capability);
901
        $data = $this->get_enrolled_users_setup($capability);
902
 
902
 
Línea 919... Línea 919...
919
 
919
 
920
 
920
 
921
    /**
921
    /**
922
     * Test get_enrolled_users last course access.
922
     * Test get_enrolled_users last course access.
923
     */
923
     */
924
    public function test_get_enrolled_users_including_lastcourseaccess() {
924
    public function test_get_enrolled_users_including_lastcourseaccess(): void {
925
        global $DB;
925
        global $DB;
Línea 926... Línea 926...
926
        $capability = 'moodle/course:viewparticipants';
926
        $capability = 'moodle/course:viewparticipants';
Línea 959... Línea 959...
959
 
959
 
960
    /**
960
    /**
961
     * Test get_enrolled_users from core_enrol_external with capability to
961
     * Test get_enrolled_users from core_enrol_external with capability to
962
     * viewparticipants removed.
962
     * viewparticipants removed.
963
     */
963
     */
964
    public function test_get_enrolled_users_without_capability() {
964
    public function test_get_enrolled_users_without_capability(): void {
965
        $capability = 'moodle/course:viewparticipants';
965
        $capability = 'moodle/course:viewparticipants';
Línea 966... Línea 966...
966
        $data = $this->get_enrolled_users_setup($capability);
966
        $data = $this->get_enrolled_users_setup($capability);
967
 
967
 
Línea 1011... Línea 1011...
1011
    }
1011
    }
Línea 1012... Línea 1012...
1012
 
1012
 
1013
    /**
1013
    /**
1014
     * Test get_enrolled_users_with_capability without additional paramaters.
1014
     * Test get_enrolled_users_with_capability without additional paramaters.
1015
     */
1015
     */
1016
    public function test_get_enrolled_users_with_capability_without_parameters() {
1016
    public function test_get_enrolled_users_with_capability_without_parameters(): void {
1017
        $capability = 'moodle/course:viewparticipants';
1017
        $capability = 'moodle/course:viewparticipants';
Línea 1018... Línea 1018...
1018
        $data = $this->get_enrolled_users_with_capability_setup($capability);
1018
        $data = $this->get_enrolled_users_with_capability_setup($capability);
1019
 
1019
 
Línea 1040... Línea 1040...
1040
    }
1040
    }
Línea 1041... Línea 1041...
1041
 
1041
 
1042
    /**
1042
    /**
1043
     * Test get_enrolled_users_with_capability
1043
     * Test get_enrolled_users_with_capability
1044
     */
1044
     */
1045
    public function test_get_enrolled_users_with_capability_with_parameters() {
1045
    public function test_get_enrolled_users_with_capability_with_parameters(): void {
1046
        $capability = 'moodle/course:viewparticipants';
1046
        $capability = 'moodle/course:viewparticipants';
Línea 1047... Línea 1047...
1047
        $data = $this->get_enrolled_users_with_capability_setup($capability);
1047
        $data = $this->get_enrolled_users_with_capability_setup($capability);
1048
 
1048
 
Línea 1073... Línea 1073...
1073
    }
1073
    }
Línea 1074... Línea 1074...
1074
 
1074
 
1075
    /**
1075
    /**
1076
     * Test get_enrolled_users last course access.
1076
     * Test get_enrolled_users last course access.
1077
     */
1077
     */
1078
    public function test_get_enrolled_users_with_capability_including_lastcourseaccess() {
1078
    public function test_get_enrolled_users_with_capability_including_lastcourseaccess(): void {
1079
        global $DB;
1079
        global $DB;
1080
        $capability = 'moodle/course:viewparticipants';
1080
        $capability = 'moodle/course:viewparticipants';
Línea 1081... Línea 1081...
1081
        $data = $this->get_enrolled_users_with_capability_setup($capability);
1081
        $data = $this->get_enrolled_users_with_capability_setup($capability);
Línea 1123... Línea 1123...
1123
    }
1123
    }
Línea 1124... Línea 1124...
1124
 
1124
 
1125
    /**
1125
    /**
1126
     * dataProvider for test_submit_user_enrolment_form().
1126
     * dataProvider for test_submit_user_enrolment_form().
1127
     */
1127
     */
1128
    public function submit_user_enrolment_form_provider() {
1128
    public static function submit_user_enrolment_form_provider(): array {
Línea 1129... Línea 1129...
1129
        $now = new \DateTime();
1129
        $now = new \DateTime();
1130
 
1130
 
Línea 1192... Línea 1192...
1192
     * @param array $customdata The data we are providing to the webservice.
1192
     * @param array $customdata The data we are providing to the webservice.
1193
     * @param bool $expectedresult The result we are expecting to receive from the webservice.
1193
     * @param bool $expectedresult The result we are expecting to receive from the webservice.
1194
     * @param bool $validationerror The validationerror we are expecting to receive from the webservice.
1194
     * @param bool $validationerror The validationerror we are expecting to receive from the webservice.
1195
     * @dataProvider submit_user_enrolment_form_provider
1195
     * @dataProvider submit_user_enrolment_form_provider
1196
     */
1196
     */
1197
    public function test_submit_user_enrolment_form($customdata, $expectedresult, $validationerror) {
1197
    public function test_submit_user_enrolment_form($customdata, $expectedresult, $validationerror): void {
1198
        global $CFG, $DB;
1198
        global $CFG, $DB;
Línea 1199... Línea 1199...
1199
 
1199
 
1200
        $this->resetAfterTest(true);
1200
        $this->resetAfterTest(true);
Línea 1271... Línea 1271...
1271
    }
1271
    }
Línea 1272... Línea 1272...
1272
 
1272
 
1273
    /**
1273
    /**
1274
     * Test for core_enrol_external::unenrol_user_enrolment().
1274
     * Test for core_enrol_external::unenrol_user_enrolment().
1275
     */
1275
     */
1276
    public function test_unenerol_user_enrolment() {
1276
    public function test_unenerol_user_enrolment(): void {
Línea 1277... Línea 1277...
1277
        global $DB;
1277
        global $DB;
1278
 
1278
 
Línea 1336... Línea 1336...
1336
    }
1336
    }
Línea 1337... Línea 1337...
1337
 
1337
 
1338
    /**
1338
    /**
1339
     * Test for core_enrol_external::test_search_users().
1339
     * Test for core_enrol_external::test_search_users().
1340
     */
1340
     */
1341
    public function test_search_users() {
1341
    public function test_search_users(): void {
Línea 1342... Línea 1342...
1342
        global $DB;
1342
        global $DB;
1343
 
1343
 
Línea 1425... Línea 1425...
1425
 
1425
 
1426
    /**
1426
    /**
1427
     * Test for core_enrol_external::search_users() when group mode is active.
1427
     * Test for core_enrol_external::search_users() when group mode is active.
1428
     * @covers ::search_users
1428
     * @covers ::search_users
1429
     */
1429
     */
1430
    public function test_search_users_groupmode() {
1430
    public function test_search_users_groupmode(): void {
Línea 1431... Línea 1431...
1431
        global $DB;
1431
        global $DB;
1432
 
1432