[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * Basic authentication steps definitions. 20 * 21 * @package core_auth 22 * @category test 23 * @copyright 2012 David Monllaó 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. 28 29 require_once (__DIR__ . '/../../../lib/behat/behat_base.php'); 30 31 /** 32 * Log in log out steps definitions. 33 * 34 * @package core_auth 35 * @category test 36 * @copyright 2012 David Monllaó 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class behat_auth extends behat_base { 40 41 /** 42 * Logs in the user. There should exist a user with the same value as username and password. 43 * 44 * @Given /^I log in as "(?P<username_string>(?:[^"]|\\")*)"$/ 45 */ 46 public function i_log_in_as($username) { 47 // Visit login page. 48 $this->getSession()->visit($this->locate_path('login/index.php')); 49 50 // Enter username and password. 51 $this->execute('behat_forms::i_set_the_field_to', array('Username', $this->escape($username))); 52 $this->execute('behat_forms::i_set_the_field_to', array('Password', $this->escape($username))); 53 54 // Press log in button, no need to check for exceptions as it will checked after this step execution. 55 $this->execute('behat_forms::press_button', get_string('login')); 56 } 57 58 /** 59 * Logs out of the system. 60 * 61 * @Given /^I log out$/ 62 */ 63 public function i_log_out() { 64 // There is no longer any need to worry about whether the navigation 65 // bar needs to be expanded; user_menu now lives outside the 66 // hamburger. 67 68 // However, the user menu *always* needs to be expanded. if running JS. 69 if ($this->running_javascript()) { 70 $xpath = "//div[@class='usermenu']//a[contains(concat(' ', @class, ' '), ' toggle-display ')]"; 71 72 $this->execute('behat_general::i_click_on', array($xpath, "xpath_element")); 73 } 74 75 // No need to check for exceptions as it will checked after this step execution. 76 $this->execute('behat_general::click_link', get_string('logout')); 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |