Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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__ . '/../../../lib/behat/behat_deprecated_base.php');
  20  
  21  /**
  22   * Steps definitions that are now deprecated and will be removed in the next releases.
  23   *
  24   * This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
  25   * When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
  26   * file in the same directory where the steps were defined.
  27   *
  28   * @package    core_calendar
  29   * @category   test
  30   * @copyright  2022 Marina Glancy
  31   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  32   */
  33  class behat_calendar_deprecated extends behat_deprecated_base {
  34  
  35      /**
  36       * Hover over a specific day in the calendar.
  37       *
  38       * @Given /^I hover over day "(?P<dayofmonth>\d+)" of this month in the calendar$/
  39       * @param int $day The day of the current month
  40       *
  41       * @deprecated since 4.0 MDL-72810. This tested the three-month calendar pseudo block, which has been removed.
  42       * @todo MDL-73117 This will be deleted in Moodle 4.4.
  43       */
  44      public function i_hover_over_day_of_this_month_in_calendar($day) {
  45          $this->deprecated_message('behat_calendar::i_hover_over_day_of_this_month_in_mini_calendar_block');
  46  
  47          $summarytitle = userdate(time(), get_string('strftimemonthyear'));
  48          // The current month table.
  49          $currentmonth = "table[descendant::*[self::caption[contains(concat(' ', normalize-space(.), ' '), ' {$summarytitle} ')]]]";
  50  
  51          // Strings for the class cell match.
  52          $cellclasses  = "contains(concat(' ', normalize-space(@class), ' '), ' day ')";
  53          $daycontains  = "text()[contains(concat(' ', normalize-space(.), ' '), ' {$day} ')]";
  54          $daycell      = "td[{$cellclasses}]";
  55          $dayofmonth   = "a[{$daycontains}]";
  56  
  57          $xpath = '//' . $currentmonth . '/descendant::' . $daycell . '/' . $dayofmonth;
  58          $this->execute("behat_general::i_hover", [$xpath, "xpath_element"]);
  59      }
  60  
  61      /**
  62       * Click a specific day in the calendar.
  63       *
  64       * @Given /^I click day "(?P<dayofmonth>\d+)" of this month in the calendar$/
  65       * @param int $day The day of the current month
  66       *
  67       * @deprecated since 4.0 MDL-72810. This tested the three-month calendar pseudo block, which has been removed.
  68       * @todo MDL-73117 This will be deleted in Moodle 4.4.
  69       */
  70      public function i_click_day_of_this_month_in_calendar($day) {
  71          $this->deprecated_message([
  72              'behat_general::i_click_on',
  73              'behat_caendar::i_hover_over_day_of_this_month_in_full_calendar_page',
  74          ]);
  75  
  76          $summarytitle = userdate(time(), get_string('strftimemonthyear'));
  77          // The current month table.
  78          $currentmonth = "table[descendant::*[self::caption[contains(concat(' ', normalize-space(.), ' '), ' {$summarytitle} ')]]]";
  79  
  80          // Strings for the class cell match.
  81          $cellclasses  = "contains(concat(' ', normalize-space(@class), ' '), ' day ')";
  82          $daycontains  = "text()[contains(concat(' ', normalize-space(.), ' '), ' {$day} ')]";
  83          $daycell      = "td[{$cellclasses}]";
  84          $dayofmonth   = "a[{$daycontains}]";
  85  
  86          $xpath = '//' . $currentmonth . '/descendant::' . $daycell . '/' . $dayofmonth;
  87          $this->execute("behat_general::wait_until_the_page_is_ready");
  88          $this->execute("behat_general::i_click_on", array($xpath, "xpath_element"));
  89          $this->execute("behat_general::wait_until_the_page_is_ready");
  90      }
  91  }