mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
Merge branch 'MDL-64570-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
7677a86cc0
13 changed files with 175 additions and 21 deletions
|
@ -53,4 +53,37 @@ class behat_user extends behat_base {
|
|||
$this->execute("behat_general::i_click_on", array("//select[@id='formactionid']" .
|
||||
"/option[contains(., " . $nodetext . ")]", "xpath_element"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The input field should have autocomplete set to this value.
|
||||
*
|
||||
* @Then /^the field "(?P<field_string>(?:[^"]|\\")*)" should have purpose "(?P<purpose_string>(?:[^"]|\\")*)"$/
|
||||
* @param string $field The field to select.
|
||||
* @param string $purpose The expected purpose.
|
||||
*/
|
||||
public function the_field_should_have_purpose($field, $purpose) {
|
||||
$fld = behat_field_manager::get_form_field_from_label($field, $this);
|
||||
|
||||
$value = $fld->get_attribute('autocomplete');
|
||||
if ($value != $purpose) {
|
||||
$reason = 'The "' . $field . '" field does not have purpose "' . $purpose . '"';
|
||||
throw new ExpectationException($reason, $this->getSession());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The input field should not have autocomplete set to this value.
|
||||
*
|
||||
* @Then /^the field "(?P<field_string>(?:[^"]|\\")*)" should not have purpose "(?P<purpose_string>(?:[^"]|\\")*)"$/
|
||||
* @param string $field The field to select.
|
||||
* @param string $purpose The expected purpose we do not want.
|
||||
*/
|
||||
public function the_field_should_not_have_purpose($field, $purpose) {
|
||||
$fld = behat_field_manager::get_form_field_from_label($field, $this);
|
||||
|
||||
$value = $fld->get_attribute('autocomplete');
|
||||
if ($value == $purpose) {
|
||||
throw new ExpectationException('The "' . $field . '" field does have purposea "' . $purpose . '"', $this->getSession());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
43
user/tests/behat/input-purpose.feature
Normal file
43
user/tests/behat/input-purpose.feature
Normal file
|
@ -0,0 +1,43 @@
|
|||
@core @core_user
|
||||
Feature: The purpose of each input field collecting information about the user can be determined
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| unicorn | unicorn | 1 | unicorn@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category | groupmode |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| unicorn | C1 | student |
|
||||
|
||||
@javascript
|
||||
Scenario: Fields for other users are not auto filled
|
||||
When I log in as "admin"
|
||||
And I navigate to "Users > Accounts > Browse list of users" in site administration
|
||||
And I click on ".icon[title=Edit]" "css_element" in the "unicorn@example.com" "table_row"
|
||||
And I expand all fieldsets
|
||||
Then the field "Username" should not have purpose "username"
|
||||
And the field "First name" should not have purpose "given-name"
|
||||
And the field "Surname" should not have purpose "family-name"
|
||||
And the field "Email" should not have purpose "email"
|
||||
And the field "Select a country" should not have purpose "country"
|
||||
And I press "Cancel"
|
||||
And I follow "Preferred language"
|
||||
And the field "Preferred language" should not have purpose "language"
|
||||
|
||||
@javascript
|
||||
Scenario: My own user fields are auto filled
|
||||
When I log in as "unicorn"
|
||||
And I follow "Profile" in the user menu
|
||||
And I click on "Edit profile" "link" in the "region-main" "region"
|
||||
And I expand all fieldsets
|
||||
Then the field "First name" should have purpose "given-name"
|
||||
And the field "Surname" should have purpose "family-name"
|
||||
And the field "Email" should have purpose "email"
|
||||
And the field "Select a country" should have purpose "country"
|
||||
And I press "Cancel"
|
||||
And I follow "Preferences" in the user menu
|
||||
And I follow "Preferred language"
|
||||
And the field "Preferred language" should have purpose "language"
|
Loading…
Add table
Add a link
Reference in a new issue