Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 34... Línea 34...
34
 *
34
 *
35
 * @package core_backup
35
 * @package core_backup
36
 * @copyright 2014 The Open University
36
 * @copyright 2014 The Open University
37
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
38
 */
39
class moodle2_test extends \advanced_testcase {
39
final class moodle2_test extends \advanced_testcase {
Línea 40... Línea 40...
40
 
40
 
41
    /**
41
    /**
42
     * Tests the availability field on modules and sections is correctly
42
     * Tests the availability field on modules and sections is correctly
43
     * backed up and restored.
43
     * backed up and restored.
44
     */
44
     */
45
    public function test_backup_availability() {
45
    public function test_backup_availability(): void {
Línea 46... Línea 46...
46
        global $DB, $CFG;
46
        global $DB, $CFG;
47
 
47
 
48
        $this->resetAfterTest(true);
48
        $this->resetAfterTest(true);
Línea 113... Línea 113...
113
    /**
113
    /**
114
     * The availability data format was changed in Moodle 2.7. This test
114
     * The availability data format was changed in Moodle 2.7. This test
115
     * ensures that a Moodle 2.6 backup with this data can still be correctly
115
     * ensures that a Moodle 2.6 backup with this data can still be correctly
116
     * restored.
116
     * restored.
117
     */
117
     */
118
    public function test_restore_legacy_availability() {
118
    public function test_restore_legacy_availability(): void {
119
        global $DB, $USER, $CFG;
119
        global $DB, $USER, $CFG;
120
        require_once($CFG->dirroot . '/grade/querylib.php');
120
        require_once($CFG->dirroot . '/grade/querylib.php');
121
        require_once($CFG->libdir . '/completionlib.php');
121
        require_once($CFG->libdir . '/completionlib.php');
Línea 122... Línea 122...
122
 
122
 
Línea 260... Línea 260...
260
    /**
260
    /**
261
     * Tests the backup and restore of single activity to same course (duplicate)
261
     * Tests the backup and restore of single activity to same course (duplicate)
262
     * when it contains availability conditions that depend on other items in
262
     * when it contains availability conditions that depend on other items in
263
     * course.
263
     * course.
264
     */
264
     */
265
    public function test_duplicate_availability() {
265
    public function test_duplicate_availability(): void {
266
        global $DB, $CFG;
266
        global $DB, $CFG;
Línea 267... Línea 267...
267
 
267
 
268
        $this->resetAfterTest(true);
268
        $this->resetAfterTest(true);
269
        $this->setAdminUser();
269
        $this->setAdminUser();
Línea 327... Línea 327...
327
 
327
 
328
    /**
328
    /**
329
     * When restoring a course, you can change the start date, which shifts other
329
     * When restoring a course, you can change the start date, which shifts other
330
     * dates. This test checks that certain dates are correctly modified.
330
     * dates. This test checks that certain dates are correctly modified.
331
     */
331
     */
332
    public function test_restore_dates() {
332
    public function test_restore_dates(): void {
Línea 333... Línea 333...
333
        global $DB, $CFG;
333
        global $DB, $CFG;
334
 
334
 
335
        $this->resetAfterTest(true);
335
        $this->resetAfterTest(true);
Línea 385... Línea 385...
385
 
385
 
386
    /**
386
    /**
387
     * Test front page backup/restore and duplicate activities
387
     * Test front page backup/restore and duplicate activities
388
     * @return void
388
     * @return void
389
     */
389
     */
390
    public function test_restore_frontpage() {
390
    public function test_restore_frontpage(): void {
Línea 391... Línea 391...
391
        global $DB, $CFG, $USER;
391
        global $DB, $CFG, $USER;
392
 
392
 
393
        $this->resetAfterTest(true);
393
        $this->resetAfterTest(true);
Línea 646... Línea 646...
646
    }
646
    }
Línea 647... Línea 647...
647
 
647
 
648
    /**
648
    /**
649
     * Backup a course with enrolment methods and restore it without user data and without enrolment methods
649
     * Backup a course with enrolment methods and restore it without user data and without enrolment methods
650
     */
650
     */
651
    public function test_restore_without_users_without_enrolments() {
651
    public function test_restore_without_users_without_enrolments(): void {
Línea 652... Línea 652...
652
        global $DB;
652
        global $DB;
Línea 653... Línea 653...
653
 
653
 
Línea 671... Línea 671...
671
    }
671
    }
Línea 672... Línea 672...
672
 
672
 
673
    /**
673
    /**
674
     * Backup a course with enrolment methods and restore it without user data with enrolment methods
674
     * Backup a course with enrolment methods and restore it without user data with enrolment methods
675
     */
675
     */
676
    public function test_restore_without_users_with_enrolments() {
676
    public function test_restore_without_users_with_enrolments(): void {
Línea 677... Línea 677...
677
        global $DB;
677
        global $DB;
678
 
678
 
Línea 701... Línea 701...
701
    }
701
    }
Línea 702... Línea 702...
702
 
702
 
703
    /**
703
    /**
704
     * Backup a course with enrolment methods and restore it with user data and without enrolment methods
704
     * Backup a course with enrolment methods and restore it with user data and without enrolment methods
705
     */
705
     */
706
    public function test_restore_with_users_without_enrolments() {
706
    public function test_restore_with_users_without_enrolments(): void {
Línea 707... Línea 707...
707
        global $DB;
707
        global $DB;
708
 
708
 
Línea 729... Línea 729...
729
    }
729
    }
Línea 730... Línea 730...
730
 
730
 
731
    /**
731
    /**
732
     * Backup a course with enrolment methods and restore it with user data with enrolment methods
732
     * Backup a course with enrolment methods and restore it with user data with enrolment methods
733
     */
733
     */
734
    public function test_restore_with_users_with_enrolments() {
734
    public function test_restore_with_users_with_enrolments(): void {
Línea 735... Línea 735...
735
        global $DB;
735
        global $DB;
736
 
736
 
Línea 759... Línea 759...
759
    }
759
    }
Línea 760... Línea 760...
760
 
760
 
761
    /**
761
    /**
762
     * Backup a course with enrolment methods and restore it with user data with enrolment methods merging into another course
762
     * Backup a course with enrolment methods and restore it with user data with enrolment methods merging into another course
763
     */
763
     */
764
    public function test_restore_with_users_with_enrolments_merging() {
764
    public function test_restore_with_users_with_enrolments_merging(): void {
Línea 765... Línea 765...
765
        global $DB;
765
        global $DB;
766
 
766
 
Línea 789... Línea 789...
789
    }
789
    }
Línea 790... Línea 790...
790
 
790
 
791
    /**
791
    /**
792
     * Backup a course with enrolment methods and restore it with user data with enrolment methods into another course deleting it's contents
792
     * Backup a course with enrolment methods and restore it with user data with enrolment methods into another course deleting it's contents
793
     */
793
     */
794
    public function test_restore_with_users_with_enrolments_deleting() {
794
    public function test_restore_with_users_with_enrolments_deleting(): void {
Línea 795... Línea 795...
795
        global $DB;
795
        global $DB;
796
 
796
 
Línea 819... Línea 819...
819
    }
819
    }
Línea 820... Línea 820...
820
 
820
 
821
    /**
821
    /**
822
     * Test the block instance time fields (timecreated, timemodified) through a backup and restore.
822
     * Test the block instance time fields (timecreated, timemodified) through a backup and restore.
823
     */
823
     */
824
    public function test_block_instance_times_backup() {
824
    public function test_block_instance_times_backup(): void {
825
        global $DB;
825
        global $DB;
Línea 826... Línea 826...
826
        $this->resetAfterTest();
826
        $this->resetAfterTest();
827
 
827
 
Línea 880... Línea 880...
880
 
880
 
881
    /**
881
    /**
882
     * When you restore a site with global search (or search indexing) turned on, then it should
882
     * When you restore a site with global search (or search indexing) turned on, then it should
883
     * add entries to the search index requests table so that the data gets indexed.
883
     * add entries to the search index requests table so that the data gets indexed.
884
     */
884
     */
885
    public function test_restore_search_index_requests() {
885
    public function test_restore_search_index_requests(): void {
Línea 886... Línea 886...
886
        global $DB, $CFG, $USER;
886
        global $DB, $CFG, $USER;
887
 
887
 
888
        $this->resetAfterTest(true);
888
        $this->resetAfterTest(true);
Línea 968... Línea 968...
968
 
968
 
969
    /**
969
    /**
970
     * Test restoring courses based on the backup plan. Primarily used with
970
     * Test restoring courses based on the backup plan. Primarily used with
971
     * the import functionality
971
     * the import functionality
972
     */
972
     */
973
    public function test_restore_course_using_plan_defaults() {
973
    public function test_restore_course_using_plan_defaults(): void {
Línea 974... Línea 974...
974
        global $DB, $CFG, $USER;
974
        global $DB, $CFG, $USER;
975
 
975
 
976
        $this->resetAfterTest(true);
976
        $this->resetAfterTest(true);
Línea 1015... Línea 1015...
1015
    /**
1015
    /**
1016
     * The Question category hierarchical structure was changed in Moodle 3.5.
1016
     * The Question category hierarchical structure was changed in Moodle 3.5.
1017
     * From 3.5, all question categories in each context are a child of a single top level question category for that context.
1017
     * From 3.5, all question categories in each context are a child of a single top level question category for that context.
1018
     * This test ensures that both Moodle 3.4 and 3.5 backups can still be correctly restored.
1018
     * This test ensures that both Moodle 3.4 and 3.5 backups can still be correctly restored.
1019
     */
1019
     */
1020
    public function test_restore_question_category_34_35() {
1020
    public function test_restore_question_category_34_35(): void {
1021
        global $DB, $USER, $CFG;
1021
        global $DB, $USER, $CFG;
Línea 1022... Línea 1022...
1022
 
1022
 
1023
        $this->resetAfterTest(true);
1023
        $this->resetAfterTest(true);
Línea 1076... Línea 1076...
1076
    }
1076
    }
Línea 1077... Línea 1077...
1077
 
1077
 
1078
    /**
1078
    /**
1079
     * Test the content bank content through a backup and restore.
1079
     * Test the content bank content through a backup and restore.
1080
     */
1080
     */
1081
    public function test_contentbank_content_backup() {
1081
    public function test_contentbank_content_backup(): void {
1082
        global $DB, $USER, $CFG;
1082
        global $DB, $USER, $CFG;
Línea 1083... Línea 1083...
1083
        $this->resetAfterTest();
1083
        $this->resetAfterTest();
1084
 
1084
 
Línea 1107... Línea 1107...
1107
     * Test the xAPI state through a backup and restore.
1107
     * Test the xAPI state through a backup and restore.
1108
     *
1108
     *
1109
     * @covers \backup_xapistate_structure_step
1109
     * @covers \backup_xapistate_structure_step
1110
     * @covers \restore_xapistate_structure_step
1110
     * @covers \restore_xapistate_structure_step
1111
     */
1111
     */
1112
    public function test_xapistate_backup() {
1112
    public function test_xapistate_backup(): void {
1113
        global $DB;
1113
        global $DB;
1114
        $this->resetAfterTest();
1114
        $this->resetAfterTest();
1115
        $this->setAdminUser();
1115
        $this->setAdminUser();
Línea 1116... Línea 1116...
1116
 
1116
 
Línea 1144... Línea 1144...
1144
            'contextid' => \context_module::instance($activity->cmid)->id,
1144
            'contextid' => \context_module::instance($activity->cmid)->id,
1145
            'component' => 'mod_h5pactivity',
1145
            'component' => 'mod_h5pactivity',
1146
            'filearea' => 'package',
1146
            'filearea' => 'package',
1147
            'itemid' => 0,
1147
            'itemid' => 0,
1148
            'filepath' => '/',
1148
            'filepath' => '/',
1149
            'filepath' => '/',
-
 
1150
            'filename' => 'dummy.h5p',
1149
            'filename' => 'dummy.h5p',
1151
            'addxapistate' => true,
1150
            'addxapistate' => true,
1152
        ];
1151
        ];
1153
        $h5pgenerator->generate_h5p_data(false, $filerecord);
1152
        $h5pgenerator->generate_h5p_data(false, $filerecord);