forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wip-MDL-61477-master-behat' of https://github.com/marin…
- Loading branch information
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Step definition for auth_email | ||
* | ||
* @package auth_email | ||
* @category test | ||
* @copyright 2018 Marina Glancy | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); | ||
|
||
/** | ||
* Step definition for auth_email. | ||
* | ||
* @package auth_email | ||
* @category test | ||
* @copyright 2018 Marina Glancy | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class behat_auth_email extends behat_base { | ||
|
||
/** | ||
* Emulate clicking on confirmation link from the email | ||
* | ||
* @When /^I confirm email for "(?P<username>(?:[^"]|\\")*)"$/ | ||
* | ||
* @param string $username | ||
*/ | ||
public function i_confirm_email_for($username) { | ||
global $DB; | ||
$secret = $DB->get_field('user', 'secret', ['username' => $username], MUST_EXIST); | ||
$confirmationurl = new moodle_url('/login/confirm.php'); | ||
$confirmationpath = $confirmationurl->out_as_local_url(false); | ||
$url = $confirmationpath . '?' . 'data='. $secret .'/'. $username; | ||
|
||
$this->getSession()->visit($this->locate_path($url)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
@auth @auth_email | ||
Feature: User must accept policy when logging in and signing up | ||
In order to record user agreement to use the site | ||
As a user | ||
I need to be able to accept site policy during sign up | ||
|
||
Scenario: Accept policy on sign up, no site policy | ||
Given the following config values are set as admin: | ||
| registerauth | email | | ||
| passwordpolicy | 0 | | ||
And I am on site homepage | ||
And I follow "Log in" | ||
When I press "Create new account" | ||
Then I should not see "I understand and agree" | ||
And I set the following fields to these values: | ||
| Username | user1 | | ||
| Password | user1 | | ||
| Email address | user1@address.invalid | | ||
| Email (again) | user1@address.invalid | | ||
| First name | User1 | | ||
| Surname | L1 | | ||
And I press "Create my new account" | ||
And I should see "Confirm your account" | ||
And I should see "An email should have been sent to your address at [email protected]" | ||
And I confirm email for "user1" | ||
And I should see "Thanks, User1 L1" | ||
And I should see "Your registration has been confirmed" | ||
And I open my profile in edit mode | ||
And the field "First name" matches value "User1" | ||
And I log out | ||
# Confirm that user can login and browse the site (edit their profile). | ||
And I log in as "user1" | ||
And I open my profile in edit mode | ||
And the field "First name" matches value "User1" | ||
|
||
Scenario: Accept policy on sign up, with site policy | ||
Given the following config values are set as admin: | ||
| registerauth | email | | ||
| passwordpolicy | 0 | | ||
| sitepolicy | https://moodle.org | | ||
And I am on site homepage | ||
And I follow "Log in" | ||
When I press "Create new account" | ||
Then the field "I understand and agree" matches value "0" | ||
And I set the following fields to these values: | ||
| Username | user1 | | ||
| Password | user1 | | ||
| Email address | user1@address.invalid | | ||
| Email (again) | user1@address.invalid | | ||
| First name | User1 | | ||
| Surname | L1 | | ||
| I understand and agree | 1 | | ||
And I press "Create my new account" | ||
And I should see "Confirm your account" | ||
And I should see "An email should have been sent to your address at [email protected]" | ||
And I confirm email for "user1" | ||
And I should see "Thanks, User1 L1" | ||
And I should see "Your registration has been confirmed" | ||
And I open my profile in edit mode | ||
And the field "First name" matches value "User1" | ||
And I log out | ||
# Confirm that user is not asked to agree to site policy again after the next login. | ||
And I log in as "user1" | ||
And I open my profile in edit mode | ||
And the field "First name" matches value "User1" |