Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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  /**
  18   * Moodle-specific named exact selectors.
  19   *
  20   * @package    core
  21   * @category   test
  22   * @copyright  2016 Andrew Nicols
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  /**
  27   * Moodle selectors manager.
  28   *
  29   * @package    core
  30   * @copyright  2016 Andrew Nicols
  31   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  32   */
  33  class behat_exact_named_selector extends \Behat\Mink\Selector\ExactNamedSelector {
  34  
  35      // Use the named selector trait.
  36      use behat_named_selector;
  37  
  38      /**
  39       * Creates selector instance.
  40       */
  41      public function __construct() {
  42          $this->registerReplacement('%iconMatch%', "(contains(concat(' ', @class, ' '), ' icon ') or self::img)");
  43          $this->registerReplacement('%imgAltMatch%', './/*[%iconMatch% and (%altMatch% or %titleMatch%)]');
  44          parent::__construct();
  45      }
  46  
  47      /**
  48       * @var Allowed types when using text selectors arguments.
  49       */
  50      protected static $allowedtextselectors = [];
  51  
  52      /**
  53       * @var Allowed types when using selector arguments.
  54       */
  55      protected static $allowedselectors = array(
  56          'button_exact' => 'button',
  57          'checkbox_exact' => 'checkbox',
  58          'field_exact' => 'field',
  59          'fieldset_exact' => 'fieldset',
  60          'link_exact' => 'link',
  61          'link_or_button_exact' => 'link_or_button',
  62          'option_exact' => 'option',
  63          'radio_exact' => 'radio',
  64          'select_exact' => 'select',
  65          'table_exact' => 'table',
  66          'text_exact' => 'text',
  67      );
  68  
  69      /** @var List of deprecated selectors */
  70      protected static $deprecatedselectors = [];
  71  
  72      /**
  73       * Allowed selectors getter.
  74       *
  75       * @return array
  76       */
  77      public static function get_allowed_selectors() {
  78          return static::$allowedselectors;
  79      }
  80  
  81      /**
  82       * Allowed text selectors getter.
  83       *
  84       * @return array
  85       */
  86      public static function get_allowed_text_selectors() {
  87          return static::$allowedtextselectors;
  88      }
  89  }