2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Steps definitions related with blocks.
22 * @copyright 2012 David Monllaó
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
28 require_once(__DIR__ . '/../../../../blocks/tests/behat/behat_blocks.php');
31 * Blocks management steps definitions.
35 * @copyright 2012 David Monllaó
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class behat_theme_boost_behat_blocks extends behat_blocks {
40 public function i_add_the_block($blockname) {
41 $addblock = get_string('addblock');
42 $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', $addblock);
44 if (!$this->running_javascript()) {
45 $this->execute('behat_general::i_click_on_in_the', [$blockname, 'link_exact', '#region-main', 'css_element']);
47 $this->execute('behat_general::i_click_on_in_the', [$blockname, 'link_exact', $addblock, 'dialogue']);
51 public function i_open_the_blocks_action_menu($blockname) {
53 if (!$this->running_javascript()) {
54 // Action menu does not need to be open if Javascript is off.
58 // If it is already opened we do nothing.
59 $blocknode = $this->get_text_selector_node('block', $blockname);
60 if ($blocknode->hasClass('action-menu-shown')) {
64 $this->execute('behat_general::i_click_on_in_the',
65 array("a[data-toggle='dropdown']", "css_element", $this->escape($blockname), "block")
69 public function the_add_block_selector_should_contain_block($blockname) {
70 $addblock = get_string('addblock');
71 $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', $addblock);
73 $cancelstr = get_string('cancel');
74 if (!$this->running_javascript()) {
75 $this->execute('behat_general::should_exist_in_the', [$blockname, 'link_exact', '#region-main', 'css_element']);
76 $this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'link_exact', '#region-main', 'css_element']);
78 $this->execute('behat_general::should_exist_in_the', [$blockname, 'link_exact', $addblock, 'dialogue']);
79 $this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'button', $addblock, 'dialogue']);
83 public function the_add_block_selector_should_not_contain_block($blockname) {
84 $addblock = get_string('addblock');
85 $this->execute('behat_navigation::i_select_from_flat_navigation_drawer', $addblock);
87 $cancelstr = get_string('cancel');
88 if (!$this->running_javascript()) {
89 $this->execute('behat_general::should_not_exist_in_the', [$blockname, 'link_exact', '#region-main', 'css_element']);
90 $this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'link_exact', '#region-main', 'css_element']);
92 $this->execute('behat_general::should_not_exist_in_the', [$blockname, 'link_exact', $addblock, 'dialogue']);
93 $this->execute('behat_general::i_click_on_in_the', [$cancelstr, 'button', $addblock, 'dialogue']);