Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 37... Línea 37...
37
 * @package    core_course
37
 * @package    core_course
38
 * @category   external
38
 * @category   external
39
 * @copyright  2012 Jerome Mouneyrac
39
 * @copyright  2012 Jerome Mouneyrac
40
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41
 */
41
 */
42
class externallib_test extends externallib_advanced_testcase {
42
final class externallib_test extends externallib_advanced_testcase {
43
    //core_course_externallib_testcase
-
 
Línea 44... Línea 43...
44
 
43
 
45
    /**
44
    /**
46
     * Tests set up
45
     * Tests set up
47
     */
46
     */
Línea 51... Línea 50...
51
    }
50
    }
Línea 52... Línea 51...
52
 
51
 
53
    /**
52
    /**
54
     * Test create_categories
53
     * Test create_categories
55
     */
54
     */
Línea 56... Línea 55...
56
    public function test_create_categories() {
55
    public function test_create_categories(): void {
Línea 57... Línea 56...
57
 
56
 
Línea 129... Línea 128...
129
    }
128
    }
Línea 130... Línea 129...
130
 
129
 
131
    /**
130
    /**
132
     * Test delete categories
131
     * Test delete categories
133
     */
132
     */
134
    public function test_delete_categories() {
133
    public function test_delete_categories(): void {
Línea 135... Línea 134...
135
        global $DB;
134
        global $DB;
Línea 136... Línea 135...
136
 
135
 
Línea 172... Línea 171...
172
    }
171
    }
Línea 173... Línea 172...
173
 
172
 
174
    /**
173
    /**
175
     * Test get categories
174
     * Test get categories
176
     */
175
     */
177
    public function test_get_categories() {
176
    public function test_get_categories(): void {
Línea 178... Línea 177...
178
        global $DB;
177
        global $DB;
Línea 179... Línea 178...
179
 
178
 
Línea 303... Línea 302...
303
    }
302
    }
Línea 304... Línea 303...
304
 
303
 
305
    /**
304
    /**
306
     * Test update_categories
305
     * Test update_categories
307
     */
306
     */
308
    public function test_update_categories() {
307
    public function test_update_categories(): void {
Línea 309... Línea 308...
309
        global $DB;
308
        global $DB;
Línea 310... Línea 309...
310
 
309
 
Línea 366... Línea 365...
366
    }
365
    }
Línea 367... Línea 366...
367
 
366
 
368
    /**
367
    /**
369
     * Test update_categories method for moving categories
368
     * Test update_categories method for moving categories
370
     */
369
     */
371
    public function test_update_categories_moving() {
370
    public function test_update_categories_moving(): void {
Línea 372... Línea 371...
372
        $this->resetAfterTest();
371
        $this->resetAfterTest();
373
 
372
 
374
        // Create data.
373
        // Create data.
Línea 404... Línea 403...
404
    }
403
    }
Línea 405... Línea 404...
405
 
404
 
406
    /**
405
    /**
407
     * Test create_courses numsections
406
     * Test create_courses numsections
408
     */
407
     */
409
    public function test_create_course_numsections() {
408
    public function test_create_course_numsections(): void {
Línea 410... Línea 409...
410
        global $DB;
409
        global $DB;
Línea 411... Línea 410...
411
 
410
 
Línea 438... Línea 437...
438
    }
437
    }
Línea 439... Línea 438...
439
 
438
 
440
    /**
439
    /**
441
     * Test create_courses
440
     * Test create_courses
442
     */
441
     */
443
    public function test_create_courses() {
442
    public function test_create_courses(): void {
Línea 444... Línea 443...
444
        global $DB;
443
        global $DB;
Línea 445... Línea 444...
445
 
444
 
Línea 606... Línea 605...
606
     * @see test_create_courses_empty_field
605
     * @see test_create_courses_empty_field
607
     * @see test_update_courses_empty_field
606
     * @see test_update_courses_empty_field
608
     *
607
     *
609
     * @return array
608
     * @return array
610
     */
609
     */
611
    public function course_empty_field_provider(): array {
610
    public static function course_empty_field_provider(): array {
612
        return [
611
        return [
613
            [[
612
            [[
614
                'fullname' => '',
613
                'fullname' => '',
615
                'shortname' => 'ws101',
614
                'shortname' => 'ws101',
616
            ], 'fullname'],
615
            ], 'fullname'],
Línea 675... Línea 674...
675
    }
674
    }
Línea 676... Línea 675...
676
 
675
 
677
    /**
676
    /**
678
     * Test delete_courses
677
     * Test delete_courses
679
     */
678
     */
680
    public function test_delete_courses() {
679
    public function test_delete_courses(): void {
Línea 681... Línea 680...
681
        global $DB, $USER;
680
        global $DB, $USER;
Línea 682... Línea 681...
682
 
681
 
Línea 735... Línea 734...
735
    }
734
    }
Línea 736... Línea 735...
736
 
735
 
737
    /**
736
    /**
738
     * Test get_courses
737
     * Test get_courses
739
     */
738
     */
740
    public function test_get_courses() {
739
    public function test_get_courses(): void {
Línea 741... Línea 740...
741
        global $DB;
740
        global $DB;
Línea 742... Línea 741...
742
 
741
 
Línea 895... Línea 894...
895
    }
894
    }
Línea 896... Línea 895...
896
 
895
 
897
    /**
896
    /**
898
     * Test get_courses without capability
897
     * Test get_courses without capability
899
     */
898
     */
900
    public function test_get_courses_without_capability() {
899
    public function test_get_courses_without_capability(): void {
Línea 901... Línea 900...
901
        $this->resetAfterTest(true);
900
        $this->resetAfterTest(true);
902
 
901
 
Línea 921... Línea 920...
921
    }
920
    }
Línea 922... Línea 921...
922
 
921
 
923
    /**
922
    /**
924
     * Test search_courses
923
     * Test search_courses
925
     */
924
     */
Línea 926... Línea 925...
926
    public function test_search_courses() {
925
    public function test_search_courses(): void {
Línea 927... Línea 926...
927
 
926
 
928
        global $DB;
927
        global $DB;
Línea 1147... Línea 1146...
1147
    }
1146
    }
Línea 1148... Línea 1147...
1148
 
1147
 
1149
    /**
1148
    /**
1150
     * Test get_course_contents
1149
     * Test get_course_contents
1151
     */
1150
     */
1152
    public function test_get_course_contents() {
1151
    public function test_get_course_contents(): void {
1153
        global $CFG;
1152
        global $CFG;
Línea 1154... Línea 1153...
1154
        $this->resetAfterTest(true);
1153
        $this->resetAfterTest(true);
1155
 
1154
 
Línea 1297... Línea 1296...
1297
 
1296
 
1298
 
1297
 
1299
    /**
1298
    /**
1300
     * Test get_course_contents as student
1299
     * Test get_course_contents as student
1301
     */
1300
     */
1302
    public function test_get_course_contents_student() {
1301
    public function test_get_course_contents_student(): void {
Línea 1303... Línea 1302...
1303
        global $DB;
1302
        global $DB;
Línea 1345... Línea 1344...
1345
    }
1344
    }
Línea 1346... Línea 1345...
1346
 
1345
 
1347
    /**
1346
    /**
1348
     * Test get_course_contents excluding modules
1347
     * Test get_course_contents excluding modules
1349
     */
1348
     */
1350
    public function test_get_course_contents_excluding_modules() {
1349
    public function test_get_course_contents_excluding_modules(): void {
Línea 1351... Línea 1350...
1351
        $this->resetAfterTest(true);
1350
        $this->resetAfterTest(true);
Línea 1352... Línea 1351...
1352
 
1351
 
Línea 1363... Línea 1362...
1363
    }
1362
    }
Línea 1364... Línea 1363...
1364
 
1363
 
1365
    /**
1364
    /**
1366
     * Test get_course_contents excluding contents
1365
     * Test get_course_contents excluding contents
1367
     */
1366
     */
1368
    public function test_get_course_contents_excluding_contents() {
1367
    public function test_get_course_contents_excluding_contents(): void {
Línea 1369... Línea 1368...
1369
        $this->resetAfterTest(true);
1368
        $this->resetAfterTest(true);
Línea 1370... Línea 1369...
1370
 
1369
 
Línea 1387... Línea 1386...
1387
    }
1386
    }
Línea 1388... Línea 1387...
1388
 
1387
 
1389
    /**
1388
    /**
1390
     * Test get_course_contents filtering by section number
1389
     * Test get_course_contents filtering by section number
1391
     */
1390
     */
1392
    public function test_get_course_contents_section_number() {
1391
    public function test_get_course_contents_section_number(): void {
Línea 1393... Línea 1392...
1393
        $this->resetAfterTest(true);
1392
        $this->resetAfterTest(true);
Línea 1394... Línea 1393...
1394
 
1393
 
Línea 1405... Línea 1404...
1405
    }
1404
    }
Línea 1406... Línea 1405...
1406
 
1405
 
1407
    /**
1406
    /**
1408
     * Test get_course_contents filtering by cmid
1407
     * Test get_course_contents filtering by cmid
1409
     */
1408
     */
1410
    public function test_get_course_contents_cmid() {
1409
    public function test_get_course_contents_cmid(): void {
Línea 1411... Línea 1410...
1411
        $this->resetAfterTest(true);
1410
        $this->resetAfterTest(true);
Línea 1412... Línea 1411...
1412
 
1411
 
Línea 1425... Línea 1424...
1425
 
1424
 
1426
 
1425
 
1427
    /**
1426
    /**
1428
     * Test get_course_contents filtering by cmid and section
1427
     * Test get_course_contents filtering by cmid and section
1429
     */
1428
     */
Línea 1430... Línea 1429...
1430
    public function test_get_course_contents_section_cmid() {
1429
    public function test_get_course_contents_section_cmid(): void {
Línea 1431... Línea 1430...
1431
        $this->resetAfterTest(true);
1430
        $this->resetAfterTest(true);
Línea 1447... Línea 1446...
1447
    }
1446
    }
Línea 1448... Línea 1447...
1448
 
1447
 
1449
    /**
1448
    /**
1450
     * Test get_course_contents filtering by modname
1449
     * Test get_course_contents filtering by modname
1451
     */
1450
     */
1452
    public function test_get_course_contents_modname() {
1451
    public function test_get_course_contents_modname(): void {
Línea 1453... Línea 1452...
1453
        $this->resetAfterTest(true);
1452
        $this->resetAfterTest(true);
Línea 1454... Línea 1453...
1454
 
1453
 
Línea 1466... Línea 1465...
1466
    }
1465
    }
Línea 1467... Línea 1466...
1467
 
1466
 
1468
    /**
1467
    /**
1469
     * Test get_course_contents filtering by modname
1468
     * Test get_course_contents filtering by modname
1470
     */
1469
     */
1471
    public function test_get_course_contents_modid() {
1470
    public function test_get_course_contents_modid(): void {
Línea 1472... Línea 1471...
1472
        $this->resetAfterTest(true);
1471
        $this->resetAfterTest(true);
Línea 1473... Línea 1472...
1473
 
1472
 
Línea 1489... Línea 1488...
1489
    }
1488
    }
Línea 1490... Línea 1489...
1490
 
1489
 
1491
    /**
1490
    /**
1492
     * Test get_course_contents returns downloadcontent value.
1491
     * Test get_course_contents returns downloadcontent value.
1493
     */
1492
     */
1494
    public function test_get_course_contents_downloadcontent() {
1493
    public function test_get_course_contents_downloadcontent(): void {
Línea 1495... Línea 1494...
1495
        $this->resetAfterTest();
1494
        $this->resetAfterTest();
Línea 1496... Línea 1495...
1496
 
1495
 
Línea 1511... Línea 1510...
1511
    }
1510
    }
Línea 1512... Línea 1511...
1512
 
1511
 
1513
    /**
1512
    /**
1514
     * Test get course contents completion manual
1513
     * Test get course contents completion manual
1515
     */
1514
     */
1516
    public function test_get_course_contents_completion_manual() {
1515
    public function test_get_course_contents_completion_manual(): void {
1517
        global $CFG;
1516
        global $CFG;
Línea 1518... Línea 1517...
1518
        $this->resetAfterTest(true);
1517
        $this->resetAfterTest(true);
1519
 
1518
 
Línea 1585... Línea 1584...
1585
    }
1584
    }
Línea 1586... Línea 1585...
1586
 
1585
 
1587
    /**
1586
    /**
1588
     * Test get course contents completion auto
1587
     * Test get course contents completion auto
1589
     */
1588
     */
1590
    public function test_get_course_contents_completion_auto() {
1589
    public function test_get_course_contents_completion_auto(): void {
1591
        global $CFG;
1590
        global $CFG;
Línea 1592... Línea 1591...
1592
        $this->resetAfterTest(true);
1591
        $this->resetAfterTest(true);
1593
 
1592
 
Línea 1627... Línea 1626...
1627
    }
1626
    }
Línea 1628... Línea 1627...
1628
 
1627
 
1629
    /**
1628
    /**
1630
     * Test mimetype is returned for resources with showtype set.
1629
     * Test mimetype is returned for resources with showtype set.
1631
     */
1630
     */
1632
    public function test_get_course_contents_including_mimetype() {
1631
    public function test_get_course_contents_including_mimetype(): void {
Línea 1633... Línea 1632...
1633
        $this->resetAfterTest(true);
1632
        $this->resetAfterTest(true);
1634
 
1633
 
Línea 1649... Línea 1648...
1649
    }
1648
    }
Línea 1650... Línea 1649...
1650
 
1649
 
1651
    /**
1650
    /**
1652
     * Test contents info is returned.
1651
     * Test contents info is returned.
1653
     */
1652
     */
1654
    public function test_get_course_contents_contentsinfo() {
1653
    public function test_get_course_contents_contentsinfo(): void {
Línea 1655... Línea 1654...
1655
        global $USER;
1654
        global $USER;
1656
 
1655
 
1657
        $this->resetAfterTest(true);
1656
        $this->resetAfterTest(true);
Línea 1727... Línea 1726...
1727
    }
1726
    }
Línea 1728... Línea 1727...
1728
 
1727
 
1729
    /**
1728
    /**
1730
     * Test get_course_contents when hidden sections are displayed.
1729
     * Test get_course_contents when hidden sections are displayed.
1731
     */
1730
     */
1732
    public function test_get_course_contents_hiddensections() {
1731
    public function test_get_course_contents_hiddensections(): void {
1733
        global $DB;
1732
        global $DB;
Línea 1734... Línea 1733...
1734
        $this->resetAfterTest(true);
1733
        $this->resetAfterTest(true);
1735
 
1734
 
Línea 1780... Línea 1779...
1780
    }
1779
    }
Línea 1781... Línea 1780...
1781
 
1780
 
1782
    /**
1781
    /**
1783
     * Test get course contents dates.
1782
     * Test get course contents dates.
1784
     */
1783
     */
1785
    public function test_get_course_contents_dates() {
1784
    public function test_get_course_contents_dates(): void {
Línea 1786... Línea 1785...
1786
        $this->resetAfterTest(true);
1785
        $this->resetAfterTest(true);
1787
 
1786
 
Línea 1833... Línea 1832...
1833
    }
1832
    }
Línea 1834... Línea 1833...
1834
 
1833
 
1835
    /**
1834
    /**
1836
     * Test get_course_contents for courses with invalid course format.
1835
     * Test get_course_contents for courses with invalid course format.
1837
     */
1836
     */
1838
    public function test_get_course_contents_invalid_format() {
1837
    public function test_get_course_contents_invalid_format(): void {
1839
        global $DB;
1838
        global $DB;
Línea 1840... Línea 1839...
1840
        $this->resetAfterTest();
1839
        $this->resetAfterTest();
Línea 1850... Línea 1849...
1850
    }
1849
    }
Línea 1851... Línea 1850...
1851
 
1850
 
1852
    /**
1851
    /**
1853
     * Test duplicate_course
1852
     * Test duplicate_course
1854
     */
1853
     */
1855
    public function test_duplicate_course() {
1854
    public function test_duplicate_course(): void {
Línea 1856... Línea 1855...
1856
        $this->resetAfterTest(true);
1855
        $this->resetAfterTest(true);
1857
 
1856
 
1858
        // Create one course with three modules.
1857
        // Create one course with three modules.
Línea 1896... Línea 1895...
1896
    }
1895
    }
Línea 1897... Línea 1896...
1897
 
1896
 
1898
    /**
1897
    /**
1899
     * Test update_courses
1898
     * Test update_courses
1900
     */
1899
     */
1901
    public function test_update_courses() {
1900
    public function test_update_courses(): void {
Línea 1902... Línea 1901...
1902
        global $DB, $CFG, $USER, $COURSE;
1901
        global $DB, $CFG, $USER, $COURSE;
1903
 
1902
 
1904
        // Get current $COURSE to be able to restore it later (defaults to $SITE). We need this
1903
        // Get current $COURSE to be able to restore it later (defaults to $SITE). We need this
Línea 2198... Línea 2197...
2198
    }
2197
    }
Línea 2199... Línea 2198...
2199
 
2198
 
2200
    /**
2199
    /**
2201
     * Test delete course_module.
2200
     * Test delete course_module.
2202
     */
2201
     */
2203
    public function test_delete_modules() {
2202
    public function test_delete_modules(): void {
Línea 2204... Línea 2203...
2204
        global $DB;
2203
        global $DB;
2205
 
2204
 
Línea 2298... Línea 2297...
2298
    }
2297
    }
Línea 2299... Línea 2298...
2299
 
2298
 
2300
    /**
2299
    /**
2301
     * Test import_course into an empty course
2300
     * Test import_course into an empty course
2302
     */
2301
     */
2303
    public function test_import_course_empty() {
2302
    public function test_import_course_empty(): void {
Línea 2304... Línea 2303...
2304
        global $USER;
2303
        global $USER;
Línea 2305... Línea 2304...
2305
 
2304
 
Línea 2345... Línea 2344...
2345
    }
2344
    }
Línea 2346... Línea 2345...
2346
 
2345
 
2347
    /**
2346
    /**
2348
     * Test import_course into an filled course
2347
     * Test import_course into an filled course
2349
     */
2348
     */
2350
    public function test_import_course_filled() {
2349
    public function test_import_course_filled(): void {
Línea 2351... Línea 2350...
2351
        global $USER;
2350
        global $USER;
Línea 2352... Línea 2351...
2352
 
2351
 
Línea 2396... Línea 2395...
2396
    }
2395
    }
Línea 2397... Línea 2396...
2397
 
2396
 
2398
    /**
2397
    /**
2399
     * Test import_course with only blocks set to backup
2398
     * Test import_course with only blocks set to backup
2400
     */
2399
     */
2401
    public function test_import_course_blocksonly() {
2400
    public function test_import_course_blocksonly(): void {
Línea 2402... Línea 2401...
2402
        global $USER, $DB;
2401
        global $USER, $DB;
Línea 2403... Línea 2402...
2403
 
2402
 
Línea 2437... Línea 2436...
2437
    }
2436
    }
Línea 2438... Línea 2437...
2438
 
2437
 
2439
    /**
2438
    /**
2440
     * Test import_course into an filled course, deleting content.
2439
     * Test import_course into an filled course, deleting content.
2441
     */
2440
     */
2442
    public function test_import_course_deletecontent() {
2441
    public function test_import_course_deletecontent(): void {
2443
        global $USER;
2442
        global $USER;
Línea 2444... Línea 2443...
2444
        $this->resetAfterTest(true);
2443
        $this->resetAfterTest(true);
2445
 
2444
 
Línea 2485... Línea 2484...
2485
    }
2484
    }
Línea 2486... Línea 2485...
2486
 
2485
 
2487
    /**
2486
    /**
2488
     * Ensure import_course handles incorrect deletecontent option correctly.
2487
     * Ensure import_course handles incorrect deletecontent option correctly.
2489
     */
2488
     */
2490
    public function test_import_course_invalid_deletecontent_option() {
2489
    public function test_import_course_invalid_deletecontent_option(): void {
Línea 2491... Línea 2490...
2491
        $this->resetAfterTest(true);
2490
        $this->resetAfterTest(true);
2492
 
2491
 
Línea 2500... Línea 2499...
2500
    }
2499
    }
Línea 2501... Línea 2500...
2501
 
2500
 
2502
    /**
2501
    /**
2503
     * Test view_course function
2502
     * Test view_course function
2504
     */
2503
     */
Línea 2505... Línea 2504...
2505
    public function test_view_course() {
2504
    public function test_view_course(): void {
Línea 2506... Línea 2505...
2506
 
2505
 
2507
        $this->resetAfterTest();
2506
        $this->resetAfterTest();
Línea 2537... Línea 2536...
2537
    }
2536
    }
Línea 2538... Línea 2537...
2538
 
2537
 
2539
    /**
2538
    /**
2540
     * Test get_course_module
2539
     * Test get_course_module
2541
     */
2540
     */
2542
    public function test_get_course_module() {
2541
    public function test_get_course_module(): void {
Línea 2543... Línea 2542...
2543
        global $DB;
2542
        global $DB;
Línea 2544... Línea 2543...
2544
 
2543
 
Línea 2654... Línea 2653...
2654
    }
2653
    }
Línea 2655... Línea 2654...
2655
 
2654
 
2656
    /**
2655
    /**
2657
     * Test get_course_module_by_instance
2656
     * Test get_course_module_by_instance
2658
     */
2657
     */
2659
    public function test_get_course_module_by_instance() {
2658
    public function test_get_course_module_by_instance(): void {
Línea 2660... Línea 2659...
2660
        global $DB;
2659
        global $DB;
Línea 2661... Línea 2660...
2661
 
2660
 
Línea 2727... Línea 2726...
2727
    }
2726
    }
Línea 2728... Línea 2727...
2728
 
2727
 
2729
    /**
2728
    /**
2730
     * Test get_user_navigation_options
2729
     * Test get_user_navigation_options
2731
     */
2730
     */
2732
    public function test_get_user_navigation_options() {
2731
    public function test_get_user_navigation_options(): void {
Línea 2733... Línea 2732...
2733
        global $USER;
2732
        global $USER;
2734
 
2733
 
2735
        $this->resetAfterTest();
2734
        $this->resetAfterTest();
Línea 2781... Línea 2780...
2781
    }
2780
    }
Línea 2782... Línea 2781...
2782
 
2781
 
2783
    /**
2782
    /**
2784
     * Test get_user_administration_options
2783
     * Test get_user_administration_options
2785
     */
2784
     */
2786
    public function test_get_user_administration_options() {
2785
    public function test_get_user_administration_options(): void {
Línea 2787... Línea 2786...
2787
        global $USER;
2786
        global $USER;
2788
 
2787
 
2789
        $this->resetAfterTest();
2788
        $this->resetAfterTest();
Línea 2848... Línea 2847...
2848
    }
2847
    }
Línea 2849... Línea 2848...
2849
 
2848
 
2850
    /**
2849
    /**
2851
     * Test get_courses_by_fields
2850
     * Test get_courses_by_fields
2852
     */
2851
     */
2853
    public function test_get_courses_by_field() {
2852
    public function test_get_courses_by_field(): void {
2854
        global $DB, $USER;
2853
        global $DB, $USER;
Línea 2855... Línea 2854...
2855
        $this->resetAfterTest(true);
2854
        $this->resetAfterTest(true);
Línea 3155... Línea 3154...
3155
        $course = reset($result['courses']);
3154
        $course = reset($result['courses']);
3156
        $this->assertNotContains('communicationroomname', $course);
3155
        $this->assertNotContains('communicationroomname', $course);
3157
        $this->assertNotContains('communicationroomurl', $course);
3156
        $this->assertNotContains('communicationroomurl', $course);
3158
    }
3157
    }
Línea 3159... Línea 3158...
3159
 
3158
 
3160
    public function test_get_courses_by_field_invalid_field() {
3159
    public function test_get_courses_by_field_invalid_field(): void {
3161
        $this->expectException('invalid_parameter_exception');
3160
        $this->expectException('invalid_parameter_exception');
3162
        $result = core_course_external::get_courses_by_field('zyx', 'x');
3161
        $result = core_course_external::get_courses_by_field('zyx', 'x');
Línea 3163... Línea 3162...
3163
    }
3162
    }
3164
 
3163
 
3165
    public function test_get_courses_by_field_invalid_courses() {
3164
    public function test_get_courses_by_field_invalid_courses(): void {
3166
        $result = core_course_external::get_courses_by_field('id', '-1');
3165
        $result = core_course_external::get_courses_by_field('id', '-1');
3167
        $result = external_api::clean_returnvalue(core_course_external::get_courses_by_field_returns(), $result);
3166
        $result = external_api::clean_returnvalue(core_course_external::get_courses_by_field_returns(), $result);
Línea 3168... Línea 3167...
3168
        $this->assertCount(0, $result['courses']);
3167
        $this->assertCount(0, $result['courses']);
3169
    }
3168
    }
3170
 
3169
 
3171
    /**
3170
    /**
3172
     * Test get_courses_by_field_invalid_theme_and_lang
3171
     * Test get_courses_by_field_invalid_theme_and_lang
3173
     */
3172
     */
Línea 3174... Línea 3173...
3174
    public function test_get_courses_by_field_invalid_theme_and_lang() {
3173
    public function test_get_courses_by_field_invalid_theme_and_lang(): void {
3175
        $this->resetAfterTest(true);
3174
        $this->resetAfterTest(true);
Línea 3181... Línea 3180...
3181
        $this->assertEmpty($result['courses']['0']['theme']);
3180
        $this->assertEmpty($result['courses']['0']['theme']);
3182
        $this->assertEmpty($result['courses']['0']['lang']);
3181
        $this->assertEmpty($result['courses']['0']['lang']);
3183
    }
3182
    }
Línea 3184... Línea 3183...
3184
 
3183
 
3185
 
3184
 
3186
    public function test_check_updates() {
3185
    public function test_check_updates(): void {
3187
        global $DB;
3186
        global $DB;
Línea 3188... Línea 3187...
3188
        $this->resetAfterTest(true);
3187
        $this->resetAfterTest(true);
Línea 3301... Línea 3300...
3301
    }
3300
    }
Línea 3302... Línea 3301...
3302
 
3301
 
3303
    /**
3302
    /**
3304
     * Test cases for the get_enrolled_courses_by_timeline_classification test.
3303
     * Test cases for the get_enrolled_courses_by_timeline_classification test.
3305
     */
3304
     */
3306
    public function get_get_enrolled_courses_by_timeline_classification_test_cases(): array {
3305
    public static function get_get_enrolled_courses_by_timeline_classification_test_cases(): array {
3307
        $now = time();
3306
        $now = time();
Línea 3308... Línea 3307...
3308
        $day = 86400;
3307
        $day = 86400;
3309
 
3308
 
Línea 3563... Línea 3562...
3563
            'all limit and offset with wrong sort direction' => [
3562
            'all limit and offset with wrong sort direction' => [
3564
                'coursedata' => $coursedata,
3563
                'coursedata' => $coursedata,
3565
                'classification' => 'all',
3564
                'classification' => 'all',
3566
                'limit' => 5,
3565
                'limit' => 5,
3567
                'offset' => 5,
3566
                'offset' => 5,
3568
                'sort' => "ul.timeaccess abcdasc",
-
 
3569
                'expectedcourses' => [],
-
 
3570
                'expectednextoffset' => 0,
-
 
3571
                'expectedexception' => 'Invalid sort direction in $sort parameter in enrol_get_my_courses()',
-
 
3572
            ],
-
 
3573
            'all limit and offset with wrong sort direction' => [
-
 
3574
                'coursedata' => $coursedata,
-
 
3575
                'classification' => 'all',
-
 
3576
                'limit' => 5,
-
 
3577
                'offset' => 5,
-
 
3578
                'sort' => "ul.timeaccess.foo ascd",
3567
                'sort' => "ul.timeaccess.foo ascd",
3579
                'expectedcourses' => [],
3568
                'expectedcourses' => [],
3580
                'expectednextoffset' => 0,
3569
                'expectednextoffset' => 0,
3581
                'expectedexception' => 'Invalid sort direction in $sort parameter in enrol_get_my_courses()',
3570
                'expectedexception' => 'Invalid sort direction in $sort parameter in enrol_get_my_courses()',
3582
            ],
3571
            ],
Línea 3588... Línea 3577...
3588
                'sort' => "foobar",
3577
                'sort' => "foobar",
3589
                'expectedcourses' => [],
3578
                'expectedcourses' => [],
3590
                'expectednextoffset' => 0,
3579
                'expectednextoffset' => 0,
3591
                'expectedexception' => 'Invalid $sort parameter in enrol_get_my_courses()',
3580
                'expectedexception' => 'Invalid $sort parameter in enrol_get_my_courses()',
3592
            ],
3581
            ],
3593
            'all limit and offset with wrong field name' => [
-
 
3594
                'coursedata' => $coursedata,
-
 
3595
                'classification' => 'all',
-
 
3596
                'limit' => 5,
-
 
3597
                'offset' => 5,
-
 
3598
                'sort' => "ul.foobar",
-
 
3599
                'expectedcourses' => [],
-
 
3600
                'expectednextoffset' => 0,
-
 
3601
                'expectedexception' => 'Invalid $sort parameter in enrol_get_my_courses()',
-
 
3602
            ],
-
 
3603
            'all limit and offset with wrong field separator' => [
3582
            'all limit and offset with wrong field separator' => [
3604
                'coursedata' => $coursedata,
3583
                'coursedata' => $coursedata,
3605
                'classification' => 'all',
3584
                'classification' => 'all',
3606
                'limit' => 5,
3585
                'limit' => 5,
3607
                'offset' => 5,
3586
                'offset' => 5,
Línea 3745... Línea 3724...
3745
        $sort,
3724
        $sort,
3746
        $expectedcourses,
3725
        $expectedcourses,
3747
        $expectednextoffset,
3726
        $expectednextoffset,
3748
        $expectedexception = null,
3727
        $expectedexception = null,
3749
        $searchvalue = null
3728
        $searchvalue = null
3750
    ) {
3729
    ): void {
3751
        $this->resetAfterTest();
3730
        $this->resetAfterTest();
3752
        $generator = $this->getDataGenerator();
3731
        $generator = $this->getDataGenerator();
Línea 3753... Línea 3732...
3753
 
3732
 
3754
        $courses = array_map(function($coursedata) use ($generator) {
3733
        $courses = array_map(function($coursedata) use ($generator) {
Línea 3795... Línea 3774...
3795
    }
3774
    }
Línea 3796... Línea 3775...
3796
 
3775
 
3797
    /**
3776
    /**
3798
     * Test the get_recent_courses function.
3777
     * Test the get_recent_courses function.
3799
     */
3778
     */
3800
    public function test_get_recent_courses() {
3779
    public function test_get_recent_courses(): void {
Línea 3801... Línea 3780...
3801
        global $USER, $DB;
3780
        global $USER, $DB;
3802
 
3781
 
Línea 3877... Línea 3856...
3877
    }
3856
    }
Línea 3878... Línea 3857...
3878
 
3857
 
3879
    /**
3858
    /**
3880
     * Test get enrolled users by cmid function.
3859
     * Test get enrolled users by cmid function.
3881
     */
3860
     */
3882
    public function test_get_enrolled_users_by_cmid() {
3861
    public function test_get_enrolled_users_by_cmid(): void {
3883
        global $PAGE;
3862
        global $PAGE;
Línea 3884... Línea 3863...
3884
        $this->resetAfterTest(true);
3863
        $this->resetAfterTest(true);
3885
 
3864
 
Línea 3977... Línea 3956...
3977
    }
3956
    }
Línea 3978... Línea 3957...
3978
 
3957
 
3979
    /**
3958
    /**
3980
     * Verify that content items can be added to user favourites.
3959
     * Verify that content items can be added to user favourites.
3981
     */
3960
     */
3982
    public function test_add_content_item_to_user_favourites() {
3961
    public function test_add_content_item_to_user_favourites(): void {
Línea 3983... Línea 3962...
3983
        $this->resetAfterTest();
3962
        $this->resetAfterTest();
3984
 
3963
 
3985
        $course = $this->getDataGenerator()->create_course();
3964
        $course = $this->getDataGenerator()->create_course();
Línea 4015... Línea 3994...
4015
    }
3994
    }
Línea 4016... Línea 3995...
4016
 
3995
 
4017
    /**
3996
    /**
4018
     * Verify that content items can be removed from user favourites.
3997
     * Verify that content items can be removed from user favourites.
4019
     */
3998
     */
4020
    public function test_remove_content_item_from_user_favourites() {
3999
    public function test_remove_content_item_from_user_favourites(): void {
Línea 4021... Línea 4000...
4021
        $this->resetAfterTest();
4000
        $this->resetAfterTest();
4022
 
4001
 
4023
        $course = $this->getDataGenerator()->create_course();
4002
        $course = $this->getDataGenerator()->create_course();
Línea 4055... Línea 4034...
4055
    }
4034
    }
Línea 4056... Línea 4035...
4056
 
4035
 
4057
    /**
4036
    /**
4058
     * Test the web service returning course content items for inclusion in activity choosers, etc.
4037
     * Test the web service returning course content items for inclusion in activity choosers, etc.
4059
     */
4038
     */
4060
    public function test_get_course_content_items() {
4039
    public function test_get_course_content_items(): void {
Línea 4061... Línea 4040...
4061
        $this->resetAfterTest();
4040
        $this->resetAfterTest();
4062
 
4041
 
Línea 4081... Línea 4060...
4081
    }
4060
    }
Línea 4082... Línea 4061...
4082
 
4061
 
4083
    /**
4062
    /**
4084
     * Test the web service returning course content items, specifically in case where the user can't manage activities.
4063
     * Test the web service returning course content items, specifically in case where the user can't manage activities.
4085
     */
4064
     */
4086
    public function test_get_course_content_items_no_permission_to_manage() {
4065
    public function test_get_course_content_items_no_permission_to_manage(): void {
Línea 4087... Línea 4066...
4087
        $this->resetAfterTest();
4066
        $this->resetAfterTest();
4088
 
4067
 
Línea 4098... Línea 4077...
4098
    }
4077
    }
Línea 4099... Línea 4078...
4099
 
4078
 
4100
    /**
4079
    /**
4101
     * Test toggling the recommendation of an activity.
4080
     * Test toggling the recommendation of an activity.
4102
     */
4081
     */
4103
    public function test_toggle_activity_recommendation() {
4082
    public function test_toggle_activity_recommendation(): void {
Línea 4104... Línea 4083...
4104
        global $CFG;
4083
        global $CFG;
Línea 4105... Línea 4084...
4105
 
4084