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.

Differences Between: [Versions 400 and 402] [Versions 400 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   * Step definitions related to blocks overrides for the Classic theme.
  19   *
  20   * @package    theme_classic
  21   * @category   test
  22   * @copyright  2019 Michael Hawkins
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
  27  
  28  require_once (__DIR__ . '/../../../../blocks/tests/behat/behat_blocks.php');
  29  
  30  /**
  31   * Blocks management step definitions for the Classic theme.
  32   *
  33   * @package    theme_classic
  34   * @category   test
  35   * @copyright  2019 Michael Hawkins
  36   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class behat_theme_classic_behat_blocks extends behat_blocks {
  39  
  40      /**
  41       * Adds the selected block. Editing mode must be previously enabled.
  42       *
  43       * @param string $blockname
  44       * @return void
  45       */
  46      public function i_add_the_block($blockname) {
  47          $this->execute('behat_forms::i_set_the_field_to',
  48                  array("bui_addblock", $this->escape($blockname))
  49          );
  50  
  51          // If we are running without javascript we need to submit the form.
  52          if (!$this->running_javascript()) {
  53              $this->execute('behat_general::i_click_on_in_the',
  54                      array(get_string('go'), "button", "#add_block", "css_element")
  55              );
  56          }
  57      }
  58  
  59      /**
  60       * Ensures that block can be added to the page, but does not add it.
  61       *
  62       * @param string $blockname
  63       * @return void
  64       */
  65      public function the_add_block_selector_should_contain_block($blockname) {
  66          $this->execute('behat_forms::the_select_box_should_contain', [get_string('addblock'), $blockname]);
  67      }
  68  
  69      /**
  70       * Ensures that block cannot be added to the page.
  71       *
  72       * @param string $blockname
  73       * @return void
  74       */
  75      public function the_add_block_selector_should_not_contain_block($blockname) {
  76          $this->execute('behat_forms::the_select_box_should_not_contain', [get_string('addblock'), $blockname]);
  77      }
  78  }