See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace mod_assign; 18 19 defined('MOODLE_INTERNAL') || die(); 20 21 global $CFG; 22 require_once($CFG->dirroot . '/mod/assign/locallib.php'); 23 require_once($CFG->dirroot . '/mod/assign/upgradelib.php'); 24 require_once($CFG->dirroot . '/mod/assignment/lib.php'); 25 26 /** 27 * Unit tests for (some of) mod/assign/upgradelib.php. 28 * 29 * @package mod_assign 30 * @category test 31 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class upgradelib_test extends \advanced_testcase { 35 36 /** 37 * Data provider for assignment upgrade. 38 * 39 * @return array 40 */ 41 public function assignment_upgrade_provider() { 42 return [ 43 'upload' => [ 44 'type' => 'upload', 45 'submissionplugins' => [ 46 'onlinetext' => true, 47 'comments' => true, 48 'file' => false, 49 ], 50 'feedbackplugins' => [ 51 'comments' => false, 52 'file' => false, 53 'offline' => true, 54 ], 55 ], 56 'uploadsingle' => [ 57 'type' => 'uploadsingle', 58 'submissionplugins' => [ 59 'onlinetext' => true, 60 'comments' => true, 61 'file' => false, 62 ], 63 'feedbackplugins' => [ 64 'comments' => false, 65 'file' => false, 66 'offline' => true, 67 ], 68 ], 69 'online' => [ 70 'type' => 'online', 71 'submissionplugins' => [ 72 'onlinetext' => false, 73 'comments' => true, 74 'file' => true, 75 ], 76 'feedbackplugins' => [ 77 'comments' => false, 78 'file' => true, 79 'offline' => true, 80 ], 81 ], 82 'offline' => [ 83 'type' => 'offline', 84 'submissionplugins' => [ 85 'onlinetext' => true, 86 'comments' => true, 87 'file' => true, 88 ], 89 'feedbackplugins' => [ 90 'comments' => false, 91 'file' => true, 92 'offline' => true, 93 ], 94 ], 95 ]; 96 } 97 98 /** 99 * Test assigment upgrade. 100 * 101 * @dataProvider assignment_upgrade_provider 102 * @param string $type The type of assignment 103 * @param array $plugins Which plugins shuld or shoudl not be enabled 104 */ 105 public function test_upgrade_assignment($type, $plugins) { 106 global $DB, $CFG; 107 108 $this->resetAfterTest(); 109 110 $course = $this->getDataGenerator()->create_course(); 111 $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher'); 112 113 $commentconfig = false; 114 if (!empty($CFG->usecomments)) { 115 $commentconfig = $CFG->usecomments; 116 } 117 $CFG->usecomments = false; 118 119 // Create the old assignment. 120 $this->setUser($teacher); 121 $generator = $this->getDataGenerator()->get_plugin_generator('mod_assignment'); 122 $assignment = $generator->create_instance([ 123 'course' => $course->id, 124 'assignmenttype' => $type, 125 ]); 126 127 // Run the upgrade. 128 $this->setAdminUser(); 129 $log = ''; 130 $upgrader = new \assign_upgrade_manager(); 131 132 $this->assertTrue($upgrader->upgrade_assignment($assignment->id, $log)); 133 $record = $DB->get_record('assign', ['course' => $course->id]); 134 135 $cm = get_coursemodule_from_instance('assign', $record->id); 136 $context = \context_module::instance($cm->id); 137 138 $assign = new \assign($context, $cm, $course); 139 140 foreach ($plugins as $plugin => $isempty) { 141 $plugin = $assign->get_submission_plugin_by_type($plugin); 142 $this->assertEquals($isempty, empty($plugin->is_enabled())); 143 } 144 } 145 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body