[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 * Steps definitions related with blocks. 19 * 20 * @package core_block 21 * @category test 22 * @copyright 2012 David Monllaó 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__ . '/../../../lib/behat/behat_base.php'); 29 30 use Behat\Behat\Context\Step\Given as Given; 31 32 /** 33 * Blocks management steps definitions. 34 * 35 * @package core_block 36 * @category test 37 * @copyright 2012 David Monllaó 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class behat_blocks extends behat_base { 41 42 /** 43 * Adds the selected block. Editing mode must be previously enabled. 44 * 45 * @Given /^I add the "(?P<block_name_string>(?:[^"]|\\")*)" block$/ 46 * @param string $blockname 47 */ 48 public function i_add_the_block($blockname) { 49 $steps = new Given('I set the field "bui_addblock" to "' . $this->escape($blockname) . '"'); 50 51 // If we are running without javascript we need to submit the form. 52 if (!$this->running_javascript()) { 53 $steps = array( 54 $steps, 55 new Given('I click on "' . get_string('go') . '" "button" in the "#add_block" "css_element"') 56 ); 57 } 58 return $steps; 59 } 60 61 /** 62 * Docks a block. Editing mode should be previously enabled. 63 * 64 * @Given /^I dock "(?P<block_name_string>(?:[^"]|\\")*)" block$/ 65 * @param string $blockname 66 * @return Given 67 */ 68 public function i_dock_block($blockname) { 69 70 // Looking for both title and alt. 71 $xpath = "//input[@type='image'][@title='" . get_string('dockblock', 'block', $blockname) . "' or @alt='" . get_string('addtodock', 'block') . "']"; 72 return new Given('I click on " ' . $xpath . '" "xpath_element" in the "' . $this->escape($blockname) . '" "block"'); 73 } 74 75 /** 76 * Opens a block's actions menu if it is not already opened. 77 * 78 * @Given /^I open the "(?P<block_name_string>(?:[^"]|\\")*)" blocks action menu$/ 79 * @throws DriverException The step is not available when Javascript is disabled 80 * @param string $blockname 81 * @return Given 82 */ 83 public function i_open_the_blocks_action_menu($blockname) { 84 85 if (!$this->running_javascript()) { 86 // Action menu does not need to be open if Javascript is off. 87 return; 88 } 89 90 // If it is already opened we do nothing. 91 $blocknode = $this->get_text_selector_node('block', $blockname); 92 if ($blocknode->hasClass('action-menu-shown')) { 93 return; 94 } 95 96 return new Given('I click on "a[role=\'menuitem\']" "css_element" in the "' . $this->escape($blockname) . '" "block"'); 97 } 98 99 /** 100 * Clicks on Configure block for specified block. Page must be in editing mode. 101 * 102 * Argument block_name may be either the name of the block or CSS class of the block. 103 * 104 * @Given /^I configure the "(?P<block_name_string>(?:[^"]|\\")*)" block$/ 105 * @param string $blockname 106 */ 107 public function i_configure_the_block($blockname) { 108 // Note that since $blockname may be either block name or CSS class, we can not use the exact label of "Configure" link. 109 return array( 110 new Given('I open the "'.$this->escape($blockname).'" blocks action menu'), 111 new Given('I click on "Configure" "link" in the "'.$this->escape($blockname).'" "block"') 112 ); 113 } 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |