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
class upgradelib_test extends advanced_testcase {
36
class upgradelib_test extends advanced_testcase {
Línea 37... Línea 37...
37
 
37
 
38
    /**
38
    /**
39
     * Test the {@link upgrade_stale_php_files_present() function
39
     * Test the {@link upgrade_stale_php_files_present() function
40
     */
40
     */
41
    public function test_upgrade_stale_php_files_present() {
41
    public function test_upgrade_stale_php_files_present(): void {
42
        // Just call the function, must return bool false always
42
        // Just call the function, must return bool false always
43
        // if there aren't any old files in the codebase.
43
        // if there aren't any old files in the codebase.
44
        $this->assertFalse(upgrade_stale_php_files_present());
44
        $this->assertFalse(upgrade_stale_php_files_present());
Línea 75... Línea 75...
75
        $item->id = $DB->insert_record('grade_items', $item);
75
        $item->id = $DB->insert_record('grade_items', $item);
Línea 76... Línea 76...
76
 
76
 
77
        return $DB->get_record('grade_items', array('id' => $item->id));
77
        return $DB->get_record('grade_items', array('id' => $item->id));
Línea 78... Línea 78...
78
    }
78
    }
79
 
79
 
Línea 80... Línea 80...
80
    public function test_upgrade_extra_credit_weightoverride() {
80
    public function test_upgrade_extra_credit_weightoverride(): void {
Línea 81... Línea 81...
81
        global $DB, $CFG;
81
        global $DB, $CFG;
Línea 143... Línea 143...
143
    }
143
    }
Línea 144... Línea 144...
144
 
144
 
145
    /**
145
    /**
146
     * Test the upgrade function for flagging courses with calculated grade item problems.
146
     * Test the upgrade function for flagging courses with calculated grade item problems.
147
     */
147
     */
148
    public function test_upgrade_calculated_grade_items_freeze() {
148
    public function test_upgrade_calculated_grade_items_freeze(): void {
Línea 149... Línea 149...
149
        global $DB, $CFG;
149
        global $DB, $CFG;
Línea 150... Línea 150...
150
 
150
 
Línea 277... Línea 277...
277
    }
277
    }
Línea 278... Línea 278...
278
 
278
 
279
    /**
279
    /**
280
     * Test the upgrade function for final grade after setting grade max for category and grade item.
280
     * Test the upgrade function for final grade after setting grade max for category and grade item.
281
     */
281
     */
282
    public function test_upgrade_update_category_grademax_regrade_final_grades() {
282
    public function test_upgrade_update_category_grademax_regrade_final_grades(): void {
Línea 283... Línea 283...
283
        global $DB;
283
        global $DB;
Línea 284... Línea 284...
284
 
284
 
Línea 323... Línea 323...
323
 
323
 
324
        $coursegrade = new \grade_grade($courseitem->get_final($user->id), false);
324
        $coursegrade = new \grade_grade($courseitem->get_final($user->id), false);
325
        $this->assertEquals(20, $coursegrade->finalgrade);
325
        $this->assertEquals(20, $coursegrade->finalgrade);
Línea 326... Línea 326...
326
    }
326
    }
327
 
327
 
Línea 328... Línea 328...
328
    function test_upgrade_calculated_grade_items_regrade() {
328
    function test_upgrade_calculated_grade_items_regrade(): void {
Línea 329... Línea 329...
329
        global $DB, $CFG;
329
        global $DB, $CFG;
Línea 394... Línea 394...
394
    }
394
    }
Línea 395... Línea 395...
395
 
395
 
396
    /**
396
    /**
397
     * Test that the upgrade script correctly flags courses to be frozen due to letter boundary problems.
397
     * Test that the upgrade script correctly flags courses to be frozen due to letter boundary problems.
398
     */
398
     */
399
    public function test_upgrade_course_letter_boundary() {
399
    public function test_upgrade_course_letter_boundary(): void {
400
        global $CFG, $DB;
400
        global $CFG, $DB;
Línea 401... Línea 401...
401
        $this->resetAfterTest(true);
401
        $this->resetAfterTest(true);
Línea 598... Línea 598...
598
    }
598
    }
Línea 599... Línea 599...
599
 
599
 
600
    /**
600
    /**
601
     * Test upgrade_letter_boundary_needs_freeze function.
601
     * Test upgrade_letter_boundary_needs_freeze function.
602
     */
602
     */
603
    public function test_upgrade_letter_boundary_needs_freeze() {
603
    public function test_upgrade_letter_boundary_needs_freeze(): void {
Línea 604... Línea 604...
604
        global $CFG;
604
        global $CFG;
Línea 605... Línea 605...
605
 
605
 
Línea 685... Línea 685...
685
    }
685
    }
Línea 686... Línea 686...
686
 
686
 
687
    /**
687
    /**
688
     * Test libcurl custom check api.
688
     * Test libcurl custom check api.
689
     */
689
     */
690
    public function test_check_libcurl_version() {
690
    public function test_check_libcurl_version(): void {
691
        $supportedversion = 0x071304;
691
        $supportedversion = 0x071304;
692
        $curlinfo = curl_version();
692
        $curlinfo = curl_version();
Línea 693... Línea 693...
693
        $currentversion = $curlinfo['version_number'];
693
        $currentversion = $curlinfo['version_number'];
Línea 780... Línea 780...
780
     * @dataProvider serialized_strings_dataprovider
780
     * @dataProvider serialized_strings_dataprovider
781
     * @param string $initialstring The initial serialized setting.
781
     * @param string $initialstring The initial serialized setting.
782
     * @param bool $expectededited If the string is expected to be edited.
782
     * @param bool $expectededited If the string is expected to be edited.
783
     * @param string $expectedresult The expected serialized setting to be returned.
783
     * @param string $expectedresult The expected serialized setting to be returned.
784
     */
784
     */
785
    public function test_upgrade_fix_serialized_objects($initialstring, $expectededited, $expectedresult) {
785
    public function test_upgrade_fix_serialized_objects($initialstring, $expectededited, $expectedresult): void {
786
        list($edited, $resultstring) = upgrade_fix_serialized_objects($initialstring);
786
        list($edited, $resultstring) = upgrade_fix_serialized_objects($initialstring);
787
        $this->assertEquals($expectededited, $edited);
787
        $this->assertEquals($expectededited, $edited);
788
        $this->assertEquals($expectedresult, $resultstring);
788
        $this->assertEquals($expectedresult, $resultstring);
789
    }
789
    }
Línea 809... Línea 809...
809
    }
809
    }
Línea 810... Línea 810...
810
 
810
 
811
    /**
811
    /**
812
     * Check that orphaned files are deleted.
812
     * Check that orphaned files are deleted.
813
     */
813
     */
814
    public function test_upgrade_delete_orphaned_file_records() {
814
    public function test_upgrade_delete_orphaned_file_records(): void {
815
        global $DB, $CFG;
815
        global $DB, $CFG;
Línea 816... Línea 816...
816
        require_once($CFG->dirroot . '/repository/lib.php');
816
        require_once($CFG->dirroot . '/repository/lib.php');
817
 
817
 
Línea 895... Línea 895...
895
    }
895
    }
Línea 896... Línea 896...
896
 
896
 
897
    /**
897
    /**
898
     * Test the functionality of {@link upgrade_core_licenses} function.
898
     * Test the functionality of {@link upgrade_core_licenses} function.
899
     */
899
     */
900
    public function test_upgrade_core_licenses() {
900
    public function test_upgrade_core_licenses(): void {
Línea 901... Línea 901...
901
        global $CFG, $DB;
901
        global $CFG, $DB;
Línea 902... Línea 902...
902
 
902
 
Línea 935... Línea 935...
935
    }
935
    }
Línea 936... Línea 936...
936
 
936
 
937
    /**
937
    /**
938
     * Test the functionality of upgrade_calendar_events_status() function.
938
     * Test the functionality of upgrade_calendar_events_status() function.
939
     */
939
     */
Línea 940... Línea 940...
940
    public function test_upgrade_calendar_events_status() {
940
    public function test_upgrade_calendar_events_status(): void {
941
 
941
 
Línea 942... Línea 942...
942
        $this->resetAfterTest();
942
        $this->resetAfterTest();
Línea 970... Línea 970...
970
    }
970
    }
Línea 971... Línea 971...
971
 
971
 
972
    /**
972
    /**
973
     * Test the functionality of upgrade_calendar_events_get_teacherid() function.
973
     * Test the functionality of upgrade_calendar_events_get_teacherid() function.
974
     */
974
     */
975
    public function test_upgrade_calendar_events_get_teacherid() {
975
    public function test_upgrade_calendar_events_get_teacherid(): void {
Línea 976... Línea 976...
976
        global $DB;
976
        global $DB;
Línea 977... Línea 977...
977
 
977
 
Línea 999... Línea 999...
999
    }
999
    }
Línea 1000... Línea 1000...
1000
 
1000
 
1001
    /**
1001
    /**
1002
     * Test the functionality of upgrade_calendar_standard_events_fix() function.
1002
     * Test the functionality of upgrade_calendar_standard_events_fix() function.
1003
     */
1003
     */
Línea 1004... Línea 1004...
1004
    public function test_upgrade_calendar_standard_events_fix() {
1004
    public function test_upgrade_calendar_standard_events_fix(): void {
1005
 
1005
 
Línea 1006... Línea 1006...
1006
        $this->resetAfterTest();
1006
        $this->resetAfterTest();
Línea 1044... Línea 1044...
1044
    }
1044
    }
Línea 1045... Línea 1045...
1045
 
1045
 
1046
    /**
1046
    /**
1047
     * Test the functionality of upgrade_calendar_subscription_events_fix() function.
1047
     * Test the functionality of upgrade_calendar_subscription_events_fix() function.
1048
     */
1048
     */
1049
    public function test_upgrade_calendar_subscription_events_fix() {
1049
    public function test_upgrade_calendar_subscription_events_fix(): void {
Línea 1050... Línea 1050...
1050
        global $CFG, $DB;
1050
        global $CFG, $DB;
1051
 
1051
 
Línea 1111... Línea 1111...
1111
    }
1111
    }
Línea 1112... Línea 1112...
1112
 
1112
 
1113
    /**
1113
    /**
1114
     * Test the functionality of upgrade_calendar_action_events_fix() function.
1114
     * Test the functionality of upgrade_calendar_action_events_fix() function.
1115
     */
1115
     */
1116
    public function test_upgrade_calendar_action_events_fix() {
1116
    public function test_upgrade_calendar_action_events_fix(): void {
Línea 1117... Línea 1117...
1117
        global $DB;
1117
        global $DB;
1118
 
1118
 
Línea 1167... Línea 1167...
1167
    }
1167
    }
Línea 1168... Línea 1168...
1168
 
1168
 
1169
    /**
1169
    /**
1170
     * Test the user override part of upgrade_calendar_override_events_fix() function.
1170
     * Test the user override part of upgrade_calendar_override_events_fix() function.
1171
     */
1171
     */
1172
    public function test_upgrade_calendar_user_override_events_fix() {
1172
    public function test_upgrade_calendar_user_override_events_fix(): void {
Línea 1173... Línea 1173...
1173
        global $DB;
1173
        global $DB;
1174
 
1174
 
Línea 1229... Línea 1229...
1229
    }
1229
    }
Línea 1230... Línea 1230...
1230
 
1230
 
1231
    /**
1231
    /**
1232
     * Test the group override part of upgrade_calendar_override_events_fix() function.
1232
     * Test the group override part of upgrade_calendar_override_events_fix() function.
1233
     */
1233
     */
1234
    public function test_upgrade_calendar_group_override_events_fix() {
1234
    public function test_upgrade_calendar_group_override_events_fix(): void {
Línea 1235... Línea 1235...
1235
        global $DB;
1235
        global $DB;
1236
 
1236
 
Línea 1458... Línea 1458...
1458
     * Test the functionality of the {@link upgrade_add_item_to_usermenu()} function.
1458
     * Test the functionality of the {@link upgrade_add_item_to_usermenu()} function.
1459
     *
1459
     *
1460
     * @covers ::upgrade_add_item_to_usermenu
1460
     * @covers ::upgrade_add_item_to_usermenu
1461
     * @dataProvider usermenu_items_dataprovider
1461
     * @dataProvider usermenu_items_dataprovider
1462
     */
1462
     */
1463
    public function test_upgrade_add_item_to_usermenu(string $initialmenu, string $newmenuitem, string $expectedmenu) {
1463
    public function test_upgrade_add_item_to_usermenu(string $initialmenu, string $newmenuitem, string $expectedmenu): void {
1464
        global $CFG;
1464
        global $CFG;
Línea 1465... Línea 1465...
1465
 
1465
 
1466
        $this->resetAfterTest();
1466
        $this->resetAfterTest();
1467
        // Set the base user menu.
1467
        // Set the base user menu.
Línea 1475... Línea 1475...
1475
    }
1475
    }
Línea 1476... Línea 1476...
1476
 
1476
 
1477
    /**
1477
    /**
1478
     * Test that file timestamps are corrected for copied files.
1478
     * Test that file timestamps are corrected for copied files.
1479
     */
1479
     */
1480
    public function test_upgrade_fix_file_timestamps() {
1480
    public function test_upgrade_fix_file_timestamps(): void {
1481
        global $DB;
1481
        global $DB;
Línea 1482... Línea 1482...
1482
        $this->resetAfterTest();
1482
        $this->resetAfterTest();
1483
 
1483
 
Línea 1540... Línea 1540...
1540
    /**
1540
    /**
1541
     * Test the upgrade status check alongside the outageless flags.
1541
     * Test the upgrade status check alongside the outageless flags.
1542
     *
1542
     *
1543
     * @covers ::moodle_needs_upgrading
1543
     * @covers ::moodle_needs_upgrading
1544
     */
1544
     */
1545
    public function test_moodle_upgrade_check_outageless() {
1545
    public function test_moodle_upgrade_check_outageless(): void {
1546
        global $CFG;
1546
        global $CFG;
1547
        $this->resetAfterTest();
1547
        $this->resetAfterTest();
1548
        // Get a baseline.
1548
        // Get a baseline.
1549
        $this->assertFalse(moodle_needs_upgrading());
1549
        $this->assertFalse(moodle_needs_upgrading());
Línea 1563... Línea 1563...
1563
    /**
1563
    /**
1564
     * Test the upgrade status check alongside the outageless flags.
1564
     * Test the upgrade status check alongside the outageless flags.
1565
     *
1565
     *
1566
     * @covers ::upgrade_started
1566
     * @covers ::upgrade_started
1567
     */
1567
     */
1568
    public function test_moodle_start_upgrade_outageless() {
1568
    public function test_moodle_start_upgrade_outageless(): void {
1569
        global $CFG;
1569
        global $CFG;
1570
        $this->resetAfterTest();
1570
        $this->resetAfterTest();
1571
        $this->assertObjectNotHasProperty('upgraderunning', $CFG);
1571
        $this->assertObjectNotHasProperty('upgraderunning', $CFG);
Línea 1572... Línea 1572...
1572
 
1572
 
Línea 1587... Línea 1587...
1587
    /**
1587
    /**
1588
     * Test the upgrade timeout setter alongside the outageless flags.
1588
     * Test the upgrade timeout setter alongside the outageless flags.
1589
     *
1589
     *
1590
     * @covers ::upgrade_set_timeout
1590
     * @covers ::upgrade_set_timeout
1591
     */
1591
     */
1592
    public function test_moodle_set_upgrade_timeout_outageless() {
1592
    public function test_moodle_set_upgrade_timeout_outageless(): void {
1593
        global $CFG;
1593
        global $CFG;
1594
        $this->resetAfterTest();
1594
        $this->resetAfterTest();
1595
        $this->assertObjectNotHasProperty('upgraderunning', $CFG);
1595
        $this->assertObjectNotHasProperty('upgraderunning', $CFG);
Línea 1596... Línea 1596...
1596
 
1596
 
Línea 1613... Línea 1613...
1613
     *
1613
     *
1614
     * @covers ::moodle_needs_upgrading
1614
     * @covers ::moodle_needs_upgrading
1615
     * @covers ::upgrade_started
1615
     * @covers ::upgrade_started
1616
     * @covers ::upgrade_set_timeout
1616
     * @covers ::upgrade_set_timeout
1617
     */
1617
     */
1618
    public function test_upgrade_components_with_outageless() {
1618
    public function test_upgrade_components_with_outageless(): void {
1619
        global $CFG;
1619
        global $CFG;
1620
        $this->resetAfterTest();
1620
        $this->resetAfterTest();
Línea 1621... Línea 1621...
1621
 
1621
 
1622
        // We can now define the outageless constant for use in upgrade, and test the effects.
1622
        // We can now define the outageless constant for use in upgrade, and test the effects.