[ 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 * Behat groups-related steps definitions. 19 * 20 * @package core_group 21 * @category test 22 * @copyright 2013 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\Mink\Exception\ElementNotFoundException as ElementNotFoundException; 31 32 /** 33 * Groups-related steps definitions. 34 * 35 * @package core_group 36 * @category test 37 * @copyright 2013 David Monllaó 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class behat_groups extends behat_base { 41 42 /** 43 * Add the specified user to the group. You should be in the groups page when running this step. The user should be specified like "Firstname Lastname ([email protected])". 44 * 45 * @Given /^I add "(?P<user_fullname_string>(?:[^"]|\\")*)" user to "(?P<group_name_string>(?:[^"]|\\")*)" group members$/ 46 * @throws ElementNotFoundException Thrown by behat_base::find 47 * @param string $username 48 * @param string $groupname 49 */ 50 public function i_add_user_to_group_members($userfullname, $groupname) { 51 52 $userfullname = $this->getSession()->getSelectorsHandler()->xpathLiteral($userfullname); 53 54 // Using a xpath liternal to avoid problems with quotes and double quotes. 55 $groupname = $this->getSession()->getSelectorsHandler()->xpathLiteral($groupname); 56 57 // We don't know the option text as it contains the number of users in the group. 58 $select = $this->find_field('groups'); 59 $xpath = "//select[@id='groups']/descendant::option[contains(., $groupname)]"; 60 $groupoption = $this->find('xpath', $xpath); 61 $fulloption = $groupoption->getText(); 62 $select->selectOption($fulloption); 63 64 // Here we don't need to wait for the AJAX response. 65 $this->find_button(get_string('adduserstogroup', 'group'))->click(); 66 67 // Wait for add/remove members page to be loaded. 68 $this->getSession()->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS); 69 70 // Getting the option and selecting it. 71 $select = $this->find_field('addselect'); 72 $xpath = "//select[@id='addselect']/descendant::option[contains(., $userfullname)]"; 73 $memberoption = $this->find('xpath', $xpath); 74 $fulloption = $memberoption->getText(); 75 $select->selectOption($fulloption); 76 77 // Click add button. 78 $this->find_button(get_string('add'))->click(); 79 80 // Wait for the page to load. 81 $this->getSession()->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS); 82 83 // Returning to the main groups page. 84 $this->find_button(get_string('backtogroups', 'group'))->click(); 85 } 86 87 }
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 |