Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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  use Behat\Gherkin\Node\TableNode;
  20  
  21  require_once (__DIR__ . '/../../../lib/behat/behat_deprecated_base.php');
  22  
  23  /**
  24   * Steps definitions that are now deprecated and will be removed in the next releases.
  25   *
  26   * This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
  27   * When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
  28   * file in the same directory where the steps were defined.
  29   *
  30   * @package    core_enrol
  31   * @category   test
  32   * @copyright  2022 Marina Glancy
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class behat_enrol_deprecated extends behat_deprecated_base {
  36  
  37      /**
  38       * Adds the specified enrolment method to the current course filling the form with the provided data.
  39       *
  40       * @Given /^I add "(?P<enrolment_method_name_string>(?:[^"]|\\")*)" enrolment method with:$/
  41       * @param string $enrolmethod
  42       * @param TableNode $table
  43       *
  44       * @deprecated since 4.0 MDL-72090. We now need the course to enrol in. Please use i_add_enrolment_method_for_with()
  45       * @todo MDL-71733 This will be deleted in Moodle 4.4.
  46       */
  47      public function i_add_enrolment_method_with($enrolmethod, TableNode $table) {
  48          $this->deprecated_message(['behat_enrol::i_add_enrolment_method_for_with']);
  49  
  50          // Navigate to enrolment method page.
  51          $parentnodes = get_string('users', 'admin');
  52          $this->execute("behat_navigation::i_navigate_to_in_current_page_administration",
  53              array($parentnodes .' > '. get_string('type_enrol_plural', 'plugin'))
  54          );
  55  
  56          // Select enrolment method.
  57          $this->execute('behat_forms::i_select_from_the_singleselect',
  58              array($this->escape($enrolmethod), get_string('addinstance', 'enrol'))
  59          );
  60  
  61          // Wait again, for page to reloaded.
  62          $this->execute('behat_general::i_wait_to_be_redirected');
  63  
  64          // Set form fields.
  65          $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table);
  66  
  67          // Ensure we get button in focus, before pressing button.
  68          if ($this->running_javascript()) {
  69              $this->execute('behat_general::i_press_named_key', ['', 'tab']);
  70          }
  71  
  72          // Save changes.
  73          $this->execute("behat_forms::press_button", get_string('addinstance', 'enrol'));
  74      }
  75  }