Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 23... Línea 23...
23
 *
23
 *
24
 * @package    gradereport_history
24
 * @package    gradereport_history
25
 * @copyright  2014 Frédéric Massart - FMCorz.net
25
 * @copyright  2014 Frédéric Massart - FMCorz.net
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
27
 */
28
class report_test extends \advanced_testcase {
28
final class report_test extends \advanced_testcase {
Línea 29... Línea 29...
29
 
29
 
30
    /**
30
    /**
31
     * Create some grades.
31
     * Create some grades.
32
     */
32
     */
33
    public function test_query_db() {
33
    public function test_query_db(): void {
Línea 34... Línea 34...
34
        $this->resetAfterTest();
34
        $this->resetAfterTest();
35
 
35
 
36
        // Making the setup.
36
        // Making the setup.
Línea 192... Línea 192...
192
    }
192
    }
Línea 193... Línea 193...
193
 
193
 
194
    /**
194
    /**
195
     * Test the get users helper method.
195
     * Test the get users helper method.
196
     */
196
     */
197
    public function test_get_users() {
197
    public function test_get_users(): void {
Línea 198... Línea 198...
198
        $this->resetAfterTest();
198
        $this->resetAfterTest();
199
 
199
 
200
        // Making the setup.
200
        // Making the setup.
Línea 249... Línea 249...
249
     * Data provider for \gradereport_history_report_testcase::test_get_users_with_profile_fields()
249
     * Data provider for \gradereport_history_report_testcase::test_get_users_with_profile_fields()
250
     * Testing get_users() and get_users_count() test cases.
250
     * Testing get_users() and get_users_count() test cases.
251
     *
251
     *
252
     * @return array List of data sets (test cases)
252
     * @return array List of data sets (test cases)
253
     */
253
     */
254
    public function get_users_with_profile_fields_provider(): array {
254
    public static function get_users_with_profile_fields_provider(): array {
255
        return [
255
        return [
256
            // User identity check boxes, 'email', 'profile_field_lang' and 'profile_field_height' are checked.
256
            // User identity check boxes, 'email', 'profile_field_lang' and 'profile_field_height' are checked.
257
                'show email,lang and height;search for all users' =>
257
                'show email,lang and height;search for all users' =>
258
                        ['email,profile_field_lang,profile_field_height', '', ['u1', 'u2', 'u3', 'u4']],
258
                        ['email,profile_field_lang,profile_field_height', '', ['u1', 'u2', 'u3', 'u4']],
259
                'show email,lang and height;search for users on .org ' =>
259
                'show email,lang and height;search for users on .org ' =>
Línea 262... Línea 262...
262
                        ['email,profile_field_lang,profile_field_height', '.com', []],
262
                        ['email,profile_field_lang,profile_field_height', '.com', []],
263
                'show email,lang and height;search for users on .uk ' =>
263
                'show email,lang and height;search for users on .uk ' =>
264
                        ['email,profile_field_lang,profile_field_height', '.uk', ['u3']],
264
                        ['email,profile_field_lang,profile_field_height', '.uk', ['u3']],
265
                'show email,lang and height,search for Spanish speakers' =>
265
                'show email,lang and height,search for Spanish speakers' =>
266
                        ['email,profile_field_lang,profile_field_height', 'spanish', ['u1', 'u4']],
266
                        ['email,profile_field_lang,profile_field_height', 'spanish', ['u1', 'u4']],
267
                'show email,lang and height,search for Spanish speakers' =>
267
                'show email,lang and height,search for Spanish speakers (using spa)' =>
268
                        ['email,profile_field_lang,profile_field_height', 'spa', ['u1', 'u4']],
268
                        ['email,profile_field_lang,profile_field_height', 'spa', ['u1', 'u4']],
269
                'show email,lang and height,search for German speakers' =>
269
                'show email,lang and height,search for German speakers' =>
270
                        ['email,profile_field_lang,profile_field_height', 'german', ['u2']],
270
                        ['email,profile_field_lang,profile_field_height', 'german', ['u2']],
271
                'show email,lang and height,search for German speakers' =>
271
                'show email,lang and height,search for German speakers (using ger)' =>
272
                        ['email,profile_field_lang,profile_field_height', 'ger', ['u2']],
272
                        ['email,profile_field_lang,profile_field_height', 'ger', ['u2']],
273
                'show email,lang and height,search for English speakers' =>
273
                'show email,lang and height,search for English speakers' =>
274
                        ['email,profile_field_lang,profile_field_height', 'english', ['u3']],
274
                        ['email,profile_field_lang,profile_field_height', 'english', ['u3']],
275
                'show email,lang and height,search for English speakers' =>
275
                'show email,lang and height,search for English speakers (using eng)' =>
276
                        ['email,profile_field_lang,profile_field_height', 'eng', ['u3']],
276
                        ['email,profile_field_lang,profile_field_height', 'eng', ['u3']],
277
                'show email,lang and height,search for English speakers' =>
-
 
278
                        ['email,profile_field_lang,profile_field_height', 'ish', ['u3']],
-
 
279
                'show email,lang and height,search for users with height 180cm' =>
-
 
280
                        ['email,profile_field_lang,profile_field_height', '180cm', ['u2', 'u3', 'u4']],
-
 
281
                'show email,lang and height,search for users with height 180cm' =>
277
                'show email,lang and height,search for users with height 180cm' =>
282
                        ['email,profile_field_lang,profile_field_height', '180', ['u2', 'u3', 'u4']],
278
                        ['email,profile_field_lang,profile_field_height', '180', ['u2', 'u3', 'u4']],
283
                'show email,lang and height,search for users with height 170cm' =>
279
                'show email,lang and height,search for users with height 170cm' =>
284
                        ['email,profile_field_lang,profile_field_height', '170cm', ['u1']],
-
 
285
                'show email,lang and height,search for users with height 170cm' =>
-
 
286
                        ['email,profile_field_lang,profile_field_height', '170', ['u1']],
280
                        ['email,profile_field_lang,profile_field_height', '170', ['u1']],
Línea 287... Línea 281...
287
 
281
 
288
            // User identity check boxes, 'email' and 'profile_field_height' are checked.
282
            // User identity check boxes, 'email' and 'profile_field_height' are checked.
289
                'show email and height;search for users on .org' =>
283
                'show email and height;search for users on .org' =>
290
                        ['email,profile_field_height', '.org', ['u1', 'u2', 'u4']],
284
                        ['email,profile_field_height', '.org', ['u1', 'u2', 'u4']],
291
                'show email and height;search for users on .com' =>
285
                'show email and height;search for users on .com' =>
292
                        ['email,profile_field_height', '.com', []],
286
                        ['email,profile_field_height', '.com', []],
293
                'show email and height;search for users on .co' =>
287
                'show email and height;search for users on .co' =>
294
                        ['email,profile_field_height', '.co', ['u3']],
288
                        ['email,profile_field_height', '.co', ['u3']],
295
                'show email and height,search for Spanish/German/English speakers' =>
289
                'show email and height,search for Spanish speakers' =>
296
                        ['email,profile_field_height', 'spanish', []],
290
                        ['email,profile_field_height', 'spanish', []],
297
                'show email and height,search for Spanish/German/English speakers' =>
291
                'show email and height,search for German speakers' =>
298
                        ['email,profile_field_height', 'german', []],
-
 
299
                'show email and height,search for Spanish/German/English speakers' =>
-
 
300
                        ['email,profile_field_height', 'english', []],
-
 
301
                'show email,lang and height,search for English speakers' =>
-
 
302
                        ['email,profile_field_height', 'english', []],
292
                        ['email,profile_field_height', 'german', []],
303
                'show email and height,search for English speakers' =>
-
 
304
                        ['email,profile_field_height', 'eng', []],
-
 
305
                'show email and height,search for English speakers' =>
293
                'show email and height,search for English speakers' =>
306
                        ['email,profile_field_height', 'ish', []],
294
                        ['email,profile_field_height', 'english', []],
307
                'show email and height,search for users with height 180cm' =>
-
 
308
                        ['email,profile_field_height', '180cm', ['u2', 'u3', 'u4']],
-
 
309
                'show email,lang and height,search for users with height 180cm' =>
295
                'show email and height,search for users with height 180cm' =>
310
                        ['email,profile_field_height', '180', ['u2', 'u3', 'u4']],
296
                        ['email,profile_field_height', '180', ['u2', 'u3', 'u4']],
311
                'show email,lang and height,search for users with height 170cm' =>
-
 
312
                        ['email,profile_field_height', '170cm', ['u1']],
-
 
313
                'show email,lang and height,search for users with height 170cm' =>
297
                'show email and height,search for users with height 170cm' =>
Línea 314... Línea 298...
314
                        ['email,profile_field_height', '170', ['u1']],
298
                        ['email,profile_field_height', '170', ['u1']],
315
 
299
 
316
            // User identity check boxes, only 'email' is checked.
300
            // User identity check boxes, only 'email' is checked.
Línea 320... Línea 304...
320
                'show email only;search for users on .uk' => ['email', '.uk', ['u3']],
304
                'show email only;search for users on .uk' => ['email', '.uk', ['u3']],
321
                'show email only;search for users on .co' => ['email', '.co', ['u3']],
305
                'show email only;search for users on .co' => ['email', '.co', ['u3']],
322
                'show email only;search for Spanish speakers' => ['email', 'spanish', []],
306
                'show email only;search for Spanish speakers' => ['email', 'spanish', []],
323
                'show email only;search for German speakers' => ['email', 'german', []],
307
                'show email only;search for German speakers' => ['email', 'german', []],
324
                'show email only;search for English speakers' => ['email', 'english', []],
308
                'show email only;search for English speakers' => ['email', 'english', []],
325
                'show email only;search for users with height 180cm' => ['email', '180cm', []],
-
 
326
                'show email only;search for users with height 180cm' => ['email', '180', []],
309
                'show email only;search for users with height 180cm' => ['email', '180', []],
327
                'show email only;search for users with height 170cm' => ['email', '170cm', []],
-
 
328
                'show email only;search for users with height 170cm' => ['email', '170', []],
310
                'show email only;search for users with height 170cm' => ['email', '170', []],
329
        ];
311
        ];
330
    }
312
    }
Línea 331... Línea 313...
331
 
313
 
Línea 399... Línea 381...
399
    }
381
    }
Línea 400... Línea 382...
400
 
382
 
401
    /**
383
    /**
402
     * Data provider method for \gradereport_history_report_testcase::test_get_users_with_groups()
384
     * Data provider method for \gradereport_history_report_testcase::test_get_users_with_groups()
403
     */
385
     */
404
    public function get_users_provider() {
386
    public static function get_users_provider(): array {
405
        return [
387
        return [
406
            'Visible groups, non-editing teacher, not in any group' => [
388
            'Visible groups, non-editing teacher, not in any group' => [
407
                VISIBLEGROUPS, 'teacher', ['g1', 'g2'], ['s1', 's2', 's3', 's4', 's5']
389
                VISIBLEGROUPS, 'teacher', ['g1', 'g2'], ['s1', 's2', 's3', 's4', 's5']
408
            ],
390
            ],
Línea 434... Línea 416...
434
     * @param $groupmode
416
     * @param $groupmode
435
     * @param $teacherrole
417
     * @param $teacherrole
436
     * @param $teachergroups
418
     * @param $teachergroups
437
     * @param $expectedusers
419
     * @param $expectedusers
438
     */
420
     */
439
    public function test_get_users_with_groups($groupmode, $teacherrole, $teachergroups, $expectedusers) {
421
    public function test_get_users_with_groups($groupmode, $teacherrole, $teachergroups, $expectedusers): void {
440
        global $DB;
422
        global $DB;
441
        $this->resetAfterTest();
423
        $this->resetAfterTest();
Línea 442... Línea 424...
442
 
424
 
Línea 511... Línea 493...
511
    }
493
    }
Línea 512... Línea 494...
512
 
494
 
513
    /**
495
    /**
514
     * Test the get graders helper method.
496
     * Test the get graders helper method.
515
     */
497
     */
516
    public function test_graders() {
498
    public function test_graders(): void {
Línea 517... Línea 499...
517
        $this->resetAfterTest();
499
        $this->resetAfterTest();
518
 
500
 
519
        // Making the setup.
501
        // Making the setup.