Skip to content

Commit

Permalink
MDL-72090 behat: Deprecation of enrolment behat step.
Browse files Browse the repository at this point in the history
i_add_enrolment_method_with() is now deprecated, please use
i_add_enrolment_method_for_with() instead.
  • Loading branch information
abgreeve committed Dec 9, 2021
1 parent fcd4de8 commit 05a6bca
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
35 changes: 0 additions & 35 deletions enrol/tests/behat/behat_enrol.php
Expand Up @@ -39,41 +39,6 @@
*/
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.
*
Expand Down
1 change: 1 addition & 0 deletions enrol/upgrade.txt
Expand Up @@ -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 ===

Expand Down
39 changes: 39 additions & 0 deletions lib/tests/behat/behat_deprecated.php
Expand Up @@ -148,4 +148,43 @@ public function i_click_day_of_this_month_in_calendar($day) {
$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'));
}
}

0 comments on commit 05a6bca

Please sign in to comment.