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 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. 18 19 require_once (__DIR__ . '/behat_base.php'); 20 21 /** 22 * Base class for steps definitions classes that contain deprecated steps. 23 * 24 * To be extended by the deprecated steps definitions of the different Moodle components and add-ons. 25 * For example, deprecated core steps can be found in lib/tests/behat/behat_deprecated.php , 26 * deprecated steps for mod_forum would be in mod/forum/tests/behat/behat_mod_forum_deprecated.php etc. 27 * 28 * @package core 29 * @category test 30 * @copyright 2022 Marina Glancy 31 * @author David MonllaĆ³ 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class behat_deprecated_base extends behat_base { 35 36 /** 37 * Throws an exception if $CFG->behat_usedeprecated is not allowed. 38 * 39 * @throws Exception 40 * @param string|array $alternatives Alternative/s to the requested step 41 * @param bool $throwexception If set to true we always throw exception, irrespective of behat_usedeprecated setting. 42 * @return void 43 */ 44 protected function deprecated_message($alternatives, bool $throwexception = false): void { 45 global $CFG; 46 47 // We do nothing if it is enabled. 48 if (!empty($CFG->behat_usedeprecated) && !$throwexception) { 49 return; 50 } 51 52 if (is_scalar($alternatives)) { 53 $alternatives = array($alternatives); 54 } 55 56 // Show an appropriate message based on the throwexception flag. 57 if ($throwexception) { 58 $message = 'This step has been removed. Rather than using this step you can:'; 59 } else { 60 $message = 'Deprecated step, rather than using this step you can:'; 61 } 62 63 // Add all alternatives to the message. 64 foreach ($alternatives as $alternative) { 65 $message .= PHP_EOL . '- ' . $alternative; 66 } 67 68 if (!$throwexception) { 69 $message .= PHP_EOL . '- Set $CFG->behat_usedeprecated in config.php to allow the use of deprecated steps 70 if you don\'t have any other option'; 71 } 72 73 throw new Exception($message); 74 } 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body