Merge branch 'wip-mdl-50940-m28' of https://github.com/rajeshtaneja/moodle into MOODLE_28_STABLE
This commit is contained in:
@@ -137,6 +137,17 @@ Feature: Verify that all form fields values can be get and set
|
||||
And I press "Save my choice"
|
||||
And the field "one" matches value "1"
|
||||
And the field "two" matches value ""
|
||||
# Check if field xpath set/match works.
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
|
||||
And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
|
||||
And the field with xpath "//input[@name='idnumber']" does not match value ""
|
||||
And I press "Save changes"
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And the field "Course ID number" matches value "Course id number"
|
||||
|
||||
|
||||
Scenario: with JS disabled all form fields getters and setters works as expected
|
||||
|
||||
|
||||
@@ -215,7 +215,6 @@ class behat_forms extends behat_base {
|
||||
|
||||
// Checks if the provided value matches the current field value.
|
||||
if ($formfield->matches($value)) {
|
||||
$fieldvalue = $formfield->get_value();
|
||||
throw new ExpectationException(
|
||||
'The \'' . $field . '\' value matches \'' . $value . '\' and it should not match it' ,
|
||||
$this->getSession()
|
||||
@@ -223,6 +222,57 @@ class behat_forms extends behat_base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, the field matches the value.
|
||||
*
|
||||
* @Then /^the field with xpath "(?P<xpath_string>(?:[^"]|\\")*)" matches value "(?P<field_value_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ExpectationException
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $fieldxpath
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function the_field_with_xpath_matches_value($fieldxpath, $value) {
|
||||
|
||||
// Get the field.
|
||||
$fieldnode = $this->find('xpath', $fieldxpath);
|
||||
$formfield = behat_field_manager::get_form_field($fieldnode, $this->getSession());
|
||||
|
||||
// Checks if the provided value matches the current field value.
|
||||
if (!$formfield->matches($value)) {
|
||||
$fieldvalue = $formfield->get_value();
|
||||
throw new ExpectationException(
|
||||
'The \'' . $fieldxpath . '\' value is \'' . $fieldvalue . '\', \'' . $value . '\' expected' ,
|
||||
$this->getSession()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, the field does not match the value.
|
||||
*
|
||||
* @Then /^the field with xpath "(?P<xpath_string>(?:[^"]|\\")*)" does not match value "(?P<field_value_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ExpectationException
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $fieldxpath
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function the_field_with_xpath_does_not_match_value($fieldxpath, $value) {
|
||||
|
||||
// Get the field.
|
||||
$fieldnode = $this->find('xpath', $fieldxpath);
|
||||
$formfield = behat_field_manager::get_form_field($fieldnode, $this->getSession());
|
||||
|
||||
// Checks if the provided value matches the current field value.
|
||||
if ($formfield->matches($value)) {
|
||||
throw new ExpectationException(
|
||||
'The \'' . $fieldxpath . '\' value matches \'' . $value . '\' and it should not match it' ,
|
||||
$this->getSession()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, the provided field/value matches. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user