See Release Notes
Long Term Support Release
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 /** 18 * @package core_backup 19 * @category phpunit 20 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 defined('MOODLE_INTERNAL') || die(); 25 26 // Include all the needed stuff 27 global $CFG; 28 require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); 29 require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); 30 31 32 /** 33 * Instantiable class extending base_plan in order to be able to perform tests 34 */ 35 class mock_base_plan extends base_plan { 36 public function build() { 37 } 38 39 public function get_progress() { 40 return null; 41 } 42 } 43 44 /** 45 * Instantiable class extending base_step in order to be able to perform tests 46 */ 47 class mock_base_step extends base_step { 48 public function execute() { 49 } 50 } 51 52 /** 53 * Instantiable class extending backup_step in order to be able to perform tests 54 */ 55 class mock_backup_step extends backup_step { 56 public function execute() { 57 } 58 } 59 60 /** 61 * Instantiable class extending backup_task in order to mockup get_taskbasepath() 62 */ 63 class mock_backup_task_basepath extends backup_task { 64 65 /** @var string name of the mod plugin (activity) being used in the tests */ 66 private $modulename; 67 68 public function build() { 69 // Nothing to do 70 } 71 72 public function define_settings() { 73 // Nothing to do 74 } 75 76 public function get_taskbasepath() { 77 global $CFG; 78 return $CFG->tempdir . '/test'; 79 } 80 81 public function set_modulename($modulename) { 82 $this->modulename = $modulename; 83 } 84 85 public function get_modulename() { 86 return $this->modulename; 87 } 88 } 89 90 /** 91 * Instantiable class extending restore_task in order to mockup get_taskbasepath() 92 */ 93 class mock_restore_task_basepath extends restore_task { 94 95 /** @var string name of the mod plugin (activity) being used in the tests */ 96 private $modulename; 97 98 public function build() { 99 // Nothing to do. 100 } 101 102 public function define_settings() { 103 // Nothing to do. 104 } 105 106 public function set_modulename($modulename) { 107 $this->modulename = $modulename; 108 } 109 110 public function get_modulename() { 111 return $this->modulename; 112 } 113 } 114 115 /** 116 * Instantiable class extending backup_structure_step in order to be able to perform tests 117 */ 118 class mock_backup_structure_step extends backup_structure_step { 119 120 public function define_structure() { 121 122 // Create really simple structure (1 nested with 1 attr and 2 fields) 123 $test = new backup_nested_element('test', 124 array('id'), 125 array('field1', 'field2') 126 ); 127 $test->set_source_array(array(array('id' => 1, 'field1' => 'value1', 'field2' => 'value2'))); 128 129 return $test; 130 } 131 132 public function add_plugin_structure($plugintype, $element, $multiple) { 133 parent::add_plugin_structure($plugintype, $element, $multiple); 134 } 135 136 public function add_subplugin_structure($subplugintype, $element, $multiple, $plugintype = null, $pluginname = null) { 137 parent::add_subplugin_structure($subplugintype, $element, $multiple, $plugintype, $pluginname); 138 } 139 } 140 141 class mock_restore_structure_step extends restore_structure_step { 142 public function define_structure() { 143 144 // Create a really simple structure (1 element). 145 $test = new restore_path_element('test', '/tests/test'); 146 return array($test); 147 } 148 149 public function add_plugin_structure($plugintype, $element) { 150 parent::add_plugin_structure($plugintype, $element); 151 } 152 153 public function add_subplugin_structure($subplugintype, $element, $plugintype = null, $pluginname = null) { 154 parent::add_subplugin_structure($subplugintype, $element, $plugintype, $pluginname); 155 } 156 157 public function get_pathelements() { 158 return $this->pathelements; 159 } 160 } 161 162 /** 163 * Instantiable class extending activity_backup_setting to be added to task and perform tests 164 */ 165 class mock_fullpath_activity_setting extends activity_backup_setting { 166 public function process_change($setting, $ctype, $oldv) { 167 // Nothing to do 168 } 169 } 170 171 /** 172 * Instantiable class extending activity_backup_setting to be added to task and perform tests 173 */ 174 class mock_backupid_activity_setting extends activity_backup_setting { 175 public function process_change($setting, $ctype, $oldv) { 176 // Nothing to do 177 } 178 } 179 180 /** 181 * Instantiable class extending base_task in order to be able to perform tests 182 */ 183 class mock_base_task extends base_task { 184 public function build() { 185 } 186 187 public function define_settings() { 188 } 189 } 190 191 /** 192 * Instantiable class extending backup_task in order to be able to perform tests 193 */ 194 class mock_backup_task extends backup_task { 195 public function build() { 196 } 197 198 public function define_settings() { 199 } 200 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body