Skip to content

Commit

Permalink
MDL-43236 behat: Backporting new method to ease backporting future sc…
Browse files Browse the repository at this point in the history
…enarios
  • Loading branch information
David Monllao committed Mar 10, 2014
1 parent 2616d63 commit 9560500
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
17 changes: 17 additions & 0 deletions lib/tests/behat/behat_data_generators.php
Expand Up @@ -136,6 +136,23 @@ class behat_data_generators extends behat_base {
/**
* Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures.
*
* This method has been introduced in 2.7 and replaces self::the_following_exists(),
* it has been added here to make backports easier and to help 3rd parties working on new
* scenarios so they don't need to update their scenarios when they upgrade to 2.7.
*
* @Given /^the following "(?P<element_string>(?:[^"]|\\")*)" exist:$/
*
* @param string $elementname The name of the entity to add
* @param TableNode $data
*/
public function the_following_exist($elementname, TableNode $data) {
// Forwarding it.
$this->the_following_exists($elementname, $data);
}

/**
* Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures. This step will be deprecated in Moodle 2.7 in favour of 'the following "ELEMENT_STRING" exist:'.
*
* @Given /^the following "(?P<element_string>(?:[^"]|\\")*)" exists:$/
*
* @throws Exception
Expand Down
6 changes: 3 additions & 3 deletions lib/tests/behat/behat_forms.php
Expand Up @@ -84,7 +84,7 @@ public function i_set_the_following_fields_to_these_values(TableNode $data) {
}

/**
* Fills a moodle form with field/value data.
* Fills a moodle form with field/value data. This step will be deprecated in Moodle 2.7 in favour of 'I set the following fields to these values:'.
*
* @Given /^I fill the moodle form with:$/
* @throws ElementNotFoundException Thrown by behat_base::find
Expand Down Expand Up @@ -186,7 +186,7 @@ public function i_set_the_field_to($field, $value) {
}

/**
* Fills in form text field with specified id|name|label|value. It works with text-based fields.
* Fills in form text field with specified id|name|label|value. It works with text-based fields. This step will be deprecated in Moodle 2.7 in favour of 'I set the field "FIELD_STRING" to "VALUE_STRING"'.
*
* @When /^I fill in "(?P<field_string>(?:[^"]|\\")*)" with "(?P<value_string>(?:[^"]|\\")*)"$/
* @throws ElementNotFoundException Thrown by behat_base::find
Expand Down Expand Up @@ -243,7 +243,7 @@ public function uncheck_option($option) {
}

/**
* Checks that the field matches the specified value. When using multi-select fields use commas to separate selected options.
* Checks that the field matches the specified value. When using multi-select fields use commas to separate selected options. This step will be deprecated in Moodle 2.7 in favour of 'the field "FIELD_STRING" matches value "VALUE_STRING"'.
*
* @Then /^the "(?P<field_string>(?:[^"]|\\")*)" field should match "(?P<value_string>(?:[^"]|\\")*)" value$/
* @throws ExpectationException
Expand Down
39 changes: 38 additions & 1 deletion lib/tests/behat/behat_general.php
Expand Up @@ -526,7 +526,25 @@ public function the_element_should_not_be_readonly($element, $selectortype) {
/**
* Checks the provided element and selector type exists in the current page.
*
* This step is for advanced users, use it if you don't find anything else suitable for what you need.
* This method has been introduced in 2.7 and replaces self::should_exists(),
* it has been added here to make backports easier and to help 3rd parties working on new
* scenarios so they don't need to update their scenarios when they upgrade to 2.7.
*
* @Then /^"(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)" should exist$/
*
* @param string $element The locator of the specified selector
* @param string $selectortype The selector type
*/
public function should_exist($element, $selectortype) {
// Forwarding it.
$this->should_exists($element, $selectortype);
}

/**
* Checks the provided element and selector type exists in the current page. This step will be deprecated in Moodle 2.7 in favour of '"ELEMENT_STRING" "SELECTOR_STRING" should exist'.
*
* This step is for advanced users, use it if you don't find
* anything else suitable for what you need.
*
* @Then /^"(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)" should exists$/
* @throws ElementNotFoundException Thrown by behat_base::find
Expand All @@ -545,6 +563,25 @@ public function should_exists($element, $selectortype) {
/**
* Checks that the provided element and selector type not exists in the current page.
*
* This step is for advanced users, use it if you don't find
* anything else suitable for what you need.
*
* This method has been introduced in 2.7 and replaces self::should_not_exists(),
* it has been added here to make backports easier and to help 3rd parties working on new
* scenarios so they don't need to update their scenarios when they upgrade to 2.7.
*
* @Then /^"(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)" should not exist$/
* @param string $element The locator of the specified selector
* @param string $selectortype The selector type
*/
public function should_not_exist($element, $selectortype) {
// Forwarding it.
$this->should_not_exists($element, $selectortype);
}

/**
* Checks that the provided element and selector type not exists in the current page. This step will be deprecated in Moodle 2.7 in favour of '"ELEMENT_STRING" "SELECTOR_STRING" should not exist'.
*
* This step is for advanced users, use it if you don't find anything else suitable for what you need.
*
* @Then /^"(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)" should not exists$/
Expand Down

0 comments on commit 9560500

Please sign in to comment.