From 4e8c18cc860d6a3e6482a6f7fe432031cfb27121 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 6 Mar 2014 12:17:49 +0800 Subject: [PATCH] MDL-43236 behat: Backporting new method to ease backporting future scenarios --- lib/tests/behat/behat_data_generators.php | 17 ++++++++++ lib/tests/behat/behat_forms.php | 6 ++-- lib/tests/behat/behat_general.php | 39 ++++++++++++++++++++++- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/lib/tests/behat/behat_data_generators.php b/lib/tests/behat/behat_data_generators.php index 18dfb22bf57..ebd9a312c8f 100644 --- a/lib/tests/behat/behat_data_generators.php +++ b/lib/tests/behat/behat_data_generators.php @@ -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(?:[^"]|\\")*)" 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(?:[^"]|\\")*)" exists:$/ * * @throws Exception diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index fe7ac60dbe5..a6ad65c0020 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -84,7 +84,7 @@ class behat_forms extends behat_base { } /** - * 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 @@ -193,7 +193,7 @@ class behat_forms extends behat_base { } /** - * 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(?:[^"]|\\")*)" with "(?P(?:[^"]|\\")*)"$/ * @throws ElementNotFoundException Thrown by behat_base::find @@ -250,7 +250,7 @@ class behat_forms extends behat_base { } /** - * 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 should match "(?P(?:[^"]|\\")*)" value$/ * @throws ExpectationException diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index 9e2e7f8e8b9..bae9c66abca 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -788,7 +788,25 @@ class behat_general extends behat_base { /** * 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(?:[^"]|\\")*)" "(?P[^"]*)" 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(?:[^"]|\\")*)" "(?P[^"]*)" should exists$/ * @throws ElementNotFoundException Thrown by behat_base::find @@ -807,6 +825,25 @@ class behat_general extends behat_base { /** * 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(?:[^"]|\\")*)" "(?P[^"]*)" 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(?:[^"]|\\")*)" "(?P[^"]*)" should not exists$/