MDL-72090 behat: Deprecation of enrolment behat step.

i_add_enrolment_method_with() is now deprecated, please use
i_add_enrolment_method_for_with() instead.
This commit is contained in:
abgreeve 2021-12-09 09:36:15 +08:00
parent fcd4de8639
commit 05a6bca72c
3 changed files with 40 additions and 35 deletions

View File

@ -39,41 +39,6 @@ use Behat\Gherkin\Node\TableNode as TableNode;
*/
class behat_enrol extends behat_base {
/**
* Adds the specified enrolment method to the current course filling the form with the provided data.
*
* @Given /^I add "(?P<enrolment_method_name_string>(?:[^"]|\\")*)" enrolment method with:$/
* @param string $enrolmethod
* @param TableNode $table
*/
public function i_add_enrolment_method_with($enrolmethod, TableNode $table) {
// Navigate to enrolment method page.
$parentnodes = get_string('users', 'admin');
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration",
array($parentnodes .' > '. get_string('type_enrol_plural', 'plugin'))
);
// Select enrolment method.
$this->execute('behat_forms::i_select_from_the_singleselect',
array($this->escape($enrolmethod), get_string('addinstance', 'enrol'))
);
// Wait again, for page to reloaded.
$this->execute('behat_general::i_wait_to_be_redirected');
// Set form fields.
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table);
// Ensure we get button in focus, before pressing button.
if ($this->running_javascript()) {
$this->execute('behat_general::i_press_named_key', ['', 'tab']);
}
// Save changes.
$this->execute("behat_forms::press_button", get_string('addinstance', 'enrol'));
}
/**
* Add the specified enrolment method to the specified course filling the form with the provided data.
*

View File

@ -6,6 +6,7 @@ information provided here is intended especially for developers.
* Final deprecation of the following webservice:
* core_enrol_edit_user_enrolment
* External function core_enrol_external::get_users_courses now returns the last time a course was modified (timemodified field)
* The behat step i_add_enrolment_method_with() has been deprecated. Please use the new method i_add_enrolment_method_for_with()
=== 3.11 ===

View File

@ -148,4 +148,43 @@ class behat_deprecated extends behat_base {
$this->execute("behat_general::i_click_on", array($xpath, "xpath_element"));
$this->execute("behat_general::wait_until_the_page_is_ready");
}
/**
* Adds the specified enrolment method to the current course filling the form with the provided data.
*
* @Given /^I add "(?P<enrolment_method_name_string>(?:[^"]|\\")*)" enrolment method with:$/
* @param string $enrolmethod
* @param TableNode $table
*
* @deprecated since 4.0 MDL-72090. We now need the course to enrol in. Please use i_add_enrolment_method_for_with()
* @todo MDL-71733 This will be deleted in Moodle 4.4.
*/
public function i_add_enrolment_method_with($enrolmethod, TableNode $table) {
$this->deprecated_message(['i_add_enrolment_method_for_with']);
// Navigate to enrolment method page.
$parentnodes = get_string('users', 'admin');
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration",
array($parentnodes .' > '. get_string('type_enrol_plural', 'plugin'))
);
// Select enrolment method.
$this->execute('behat_forms::i_select_from_the_singleselect',
array($this->escape($enrolmethod), get_string('addinstance', 'enrol'))
);
// Wait again, for page to reloaded.
$this->execute('behat_general::i_wait_to_be_redirected');
// Set form fields.
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $table);
// Ensure we get button in focus, before pressing button.
if ($this->running_javascript()) {
$this->execute('behat_general::i_press_named_key', ['', 'tab']);
}
// Save changes.
$this->execute("behat_forms::press_button", get_string('addinstance', 'enrol'));
}
}