mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
MDL-72173 behat: Automatically log user out on behat login
This commit is contained in:
parent
93cb87cddb
commit
41ebf95bbe
@ -68,6 +68,7 @@ class behat_auth extends behat_base {
|
||||
* Logs out of the system.
|
||||
*
|
||||
* @Given /^I log out$/
|
||||
* @Given I am not logged in
|
||||
*/
|
||||
public function i_log_out() {
|
||||
$this->execute('behat_general::i_visit', [new moodle_url('/auth/tests/behat/logout.php')]);
|
||||
|
@ -35,6 +35,15 @@ if (!$behatrunning) {
|
||||
$username = required_param('username', PARAM_ALPHANUMEXT);
|
||||
$wantsurl = new moodle_url(optional_param('wantsurl', '/', PARAM_URL));
|
||||
|
||||
if (isloggedin()) {
|
||||
// If the user is already logged in, log them out and redirect them back to login again.
|
||||
require_logout();
|
||||
redirect(new moodle_url('/auth/tests/behat/login.php', [
|
||||
'username' => $username,
|
||||
'wantsurl' => $wantsurl->out(false),
|
||||
]));
|
||||
}
|
||||
|
||||
// Note - with behat, the password is always the same as the username.
|
||||
$password = $username;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user