See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
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 * Helpers for unit tests. 19 * 20 * @package tool_usertours 21 * @copyright 2016 Andrew Nicols <andrew@nicols.co.uk> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Helpers for unit tests. 29 * 30 * @package tool_usertours 31 * @copyright 2016 Andrew Nicols <andrew@nicols.co.uk> 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 trait tool_usertours_helper_trait { 35 /** 36 * A helper to create an empty tour. 37 * 38 * @param stdClass $tourconfig The configuration for the new tour 39 * @param bool $persist Whether to persist the data 40 * @return \tool_usertours\tour 41 */ 42 public function helper_create_tour(\stdClass $tourconfig = null, $persist = true) { 43 $minvalues = [ 44 'id' => null, 45 'pathmatch' => '/my/%', 46 'enabled' => true, 47 'name' => '', 48 'description' => '', 49 'configdata' => '', 50 ]; 51 52 if ($tourconfig === null) { 53 $tourconfig = new \stdClass(); 54 } 55 56 foreach ($minvalues as $key => $value) { 57 if (!isset($tourconfig->$key)) { 58 $tourconfig->$key = $value; 59 } 60 } 61 62 $tour = \tool_usertours\tour::load_from_record($tourconfig, true); 63 if ($persist) { 64 $tour->persist(true); 65 } 66 67 return $tour; 68 } 69 70 /** 71 * A helper to create an empty step for the specified tour. 72 * 73 * @param stdClass $stepconfig The configuration for the new step 74 * @param bool $persist Whether to persist the data 75 * @return \tool_usertours\step 76 */ 77 public function helper_create_step(\stdClass $stepconfig = null, $persist = true) { 78 $minvalues = [ 79 'id' => null, 80 'title' => '', 81 'content' => '', 82 'targettype' => \tool_usertours\target::TARGET_UNATTACHED, 83 'targetvalue' => '', 84 'sortorder' => 0, 85 'configdata' => '', 86 ]; 87 88 if ($stepconfig === null) { 89 $stepconfig = new \stdClass(); 90 } 91 92 foreach ($minvalues as $key => $value) { 93 if (!isset($stepconfig->$key)) { 94 $stepconfig->$key = $value; 95 } 96 } 97 98 $step = \tool_usertours\step::load_from_record($stepconfig, true); 99 if ($persist) { 100 $step->persist(true); 101 } 102 103 return $step; 104 } 105 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body