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 30 /** 31 * helper extended base_attribute class that implements some methods for instantiating and testing 32 */ 33 class mock_base_attribute extends base_attribute { 34 // Nothing to do. Just allow instances to be created 35 } 36 37 /** 38 * helper extended final_element class that implements some methods for instantiating and testing 39 */ 40 class mock_base_final_element extends base_final_element { 41 /// Implementable API 42 protected function get_new_attribute($name) { 43 return new mock_base_attribute($name); 44 } 45 } 46 47 /** 48 * helper extended nested_element class that implements some methods for instantiating and testing 49 */ 50 class mock_base_nested_element extends base_nested_element { 51 /// Implementable API 52 protected function get_new_attribute($name) { 53 return new mock_base_attribute($name); 54 } 55 56 protected function get_new_final_element($name) { 57 return new mock_base_final_element($name); 58 } 59 } 60 61 /** 62 * helper extended optigroup class that implements some methods for instantiating and testing 63 */ 64 class mock_base_optigroup extends base_optigroup { 65 /// Implementable API 66 protected function get_new_attribute($name) { 67 return new mock_base_attribute($name); 68 } 69 70 protected function get_new_final_element($name) { 71 return new mock_base_final_element($name); 72 } 73 74 public function is_multiple() { 75 return parent::is_multiple(); 76 } 77 } 78 79 /** 80 * helper class that extends backup_final_element in order to skip its value 81 */ 82 class mock_skip_final_element extends backup_final_element { 83 84 public function set_value($value) { 85 $this->clean_value(); 86 } 87 } 88 89 /** 90 * helper class that extends backup_final_element in order to modify its value 91 */ 92 class mock_modify_final_element extends backup_final_element { 93 public function set_value($value) { 94 parent::set_value('original was ' . $value . ', now changed'); 95 } 96 } 97 98 /** 99 * helper class that extends backup_final_element to delegate any calculation to another class 100 */ 101 class mock_final_element_interceptor extends backup_final_element { 102 public function set_value($value) { 103 // Get grandparent name 104 $gpname = $this->get_grandparent()->get_name(); 105 // Get parent name 106 $pname = $this->get_parent()->get_name(); 107 // Get my name 108 $myname = $this->get_name(); 109 // Define class and function name 110 $classname = 'mock_' . $gpname . '_' . $pname . '_interceptor'; 111 $methodname= 'intercept_' . $pname . '_' . $myname; 112 // Invoke the interception method 113 $result = call_user_func(array($classname, $methodname), $value); 114 // Finally set it 115 parent::set_value($result); 116 } 117 } 118 119 /** 120 * test interceptor class (its methods are called from interceptor) 121 */ 122 abstract class mock_forum_forum_interceptor { 123 static function intercept_forum_completionposts($element) { 124 return 'intercepted!'; 125 } 126 } 127 128 /** 129 * Instantiable class extending base_atom in order to be able to perform tests 130 */ 131 class mock_base_atom extends base_atom { 132 // Nothing new in this class, just an instantiable base_atom class 133 // with the is_set() method public for testing purposes 134 public function is_set() { 135 return parent::is_set(); 136 } 137 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body