mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-72090 navigation: Update to existing behat steps.
This creates new general behat steps for navigating in theme boost and classic.
This commit is contained in:
parent
89d749fda6
commit
8a5e36fa06
@ -55,15 +55,8 @@ class behat_backup extends behat_base {
|
||||
// We can not use other steps here as we don't know where the provided data
|
||||
// table elements are used, and we need to catch exceptions contantly.
|
||||
|
||||
// Go to homepage.
|
||||
$this->execute('behat_general::i_visit', ['/?redirect=0']);
|
||||
$this->execute("behat_general::wait_until_the_page_is_ready");
|
||||
|
||||
// Click the course link.
|
||||
$this->execute("behat_general::click_link", $backupcourse);
|
||||
|
||||
// Click the backup link.
|
||||
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('backup'));
|
||||
// Navigate to the course backup page.
|
||||
$this->execute("behat_navigation::i_am_on_page_instance", [$backupcourse, 'backup']);
|
||||
|
||||
// Initial settings.
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Initial"));
|
||||
@ -97,14 +90,8 @@ class behat_backup extends behat_base {
|
||||
// We can not use other steps here as we don't know where the provided data
|
||||
// table elements are used, and we need to catch exceptions contantly.
|
||||
|
||||
// Go to homepage.
|
||||
$this->execute('behat_general::i_visit', ['/?redirect=0']);
|
||||
|
||||
// Click the course link.
|
||||
$this->execute("behat_general::click_link", $backupcourse);
|
||||
|
||||
// Click the backup link.
|
||||
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('backup'));
|
||||
// Navigate to the course backup page.
|
||||
$this->execute("behat_navigation::i_am_on_page_instance", [$backupcourse, 'backup']);
|
||||
|
||||
// Initial settings.
|
||||
$this->execute("behat_forms::press_button", get_string('jumptofinalstep', 'backup'));
|
||||
@ -133,15 +120,8 @@ class behat_backup extends behat_base {
|
||||
// We can not use other steps here as we don't know where the provided data
|
||||
// table elements are used, and we need to catch exceptions contantly.
|
||||
|
||||
// Go to homepage.
|
||||
$this->execute('behat_general::i_visit', ['/?redirect=0']);
|
||||
$this->execute("behat_general::wait_until_the_page_is_ready");
|
||||
|
||||
// Click the course link.
|
||||
$this->execute("behat_general::click_link", $tocourse);
|
||||
|
||||
// Click the import link.
|
||||
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('import'));
|
||||
// Navigate to the course import page.
|
||||
$this->execute("behat_navigation::i_am_on_page_instance", [$tocourse, 'import']);
|
||||
|
||||
// Select the course.
|
||||
$fromcourse = behat_context_helper::escape($fromcourse);
|
||||
|
@ -74,6 +74,37 @@ class behat_enrol extends behat_base {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified enrolment method to the specified course filling the form with the provided data.
|
||||
*
|
||||
* @Given /^I add "(?P<enrolment_method_name_string>(?:[^"]|\\")*)" enrolment method in "(?P<course_identifier_string>(?:[^"]|\\")*)" with:$/
|
||||
* @param string $enrolmethod The enrolment method being used
|
||||
* @param string $courseidentifier The courseidentifier such as short name
|
||||
* @param TableNode $table Enrolment details
|
||||
*/
|
||||
public function i_add_enrolment_method_for_with(string $enrolmethod, string $courseidentifier, TableNode $table): void {
|
||||
$this->execute("behat_navigation::i_am_on_page_instance", [$courseidentifier, 'enrolment methods']);
|
||||
|
||||
// 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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrols the specified user in the current course without options.
|
||||
*
|
||||
@ -87,10 +118,14 @@ class behat_enrol extends behat_base {
|
||||
public function i_enrol_user_as($userfullname, $rolename) {
|
||||
|
||||
// Navigate to enrolment page.
|
||||
$parentnodes = get_string('users', 'admin');
|
||||
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration",
|
||||
array($parentnodes . ' > '. get_string('enrolledusers', 'enrol'))
|
||||
);
|
||||
try {
|
||||
$parentnodes = get_string('users', 'admin');
|
||||
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration",
|
||||
array($parentnodes . ' > '. get_string('enrolledusers', 'enrol'))
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->execute("behat_general::i_click_on", [get_string('participants'), 'link']);
|
||||
}
|
||||
|
||||
$this->execute("behat_forms::press_button", get_string('enrolusers', 'enrol'));
|
||||
|
||||
|
@ -736,11 +736,20 @@ class behat_navigation extends behat_base {
|
||||
* Recognised page names are:
|
||||
* | Page type | Identifier meaning | description |
|
||||
* | Category | category idnumber | List of courses in that category. |
|
||||
* | Course | course shortname | Main course home pag |
|
||||
* | Course | course shortname | Main course home page |
|
||||
* | Activity | activity idnumber | Start page for that activity |
|
||||
* | Activity editing | activity idnumber | Edit settings page for that activity |
|
||||
* | [modname] Activity | activity name or idnumber | Start page for that activity |
|
||||
* | [modname] Activity editing | activity name or idnumber | Edit settings page for that activity |
|
||||
* | Backup | course shortname | Course to backup |
|
||||
* | Import | course shortname | Course import from |
|
||||
* | Restore | course shortname | Course to restore from |
|
||||
* | Reset | course shortname | Course to reset |
|
||||
* | Course copy | course shortname | Course to copy |
|
||||
* | Groups | course shortname | Groups page for the course |
|
||||
* | Permissions | course shortname | Permissions page for the course |
|
||||
* | Enrolment methods | course shortname | Enrolment methods for the course |
|
||||
* | Enrolled users | course shortname | The main participants page |
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
@ -787,6 +796,71 @@ class behat_navigation extends behat_base {
|
||||
return new moodle_url('/course/modedit.php', [
|
||||
'update' => $cm->id,
|
||||
]);
|
||||
case 'backup':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/backup/backup.php', ['id' => $courseid]);
|
||||
case 'import':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/backup/import.php', ['id' => $courseid]);
|
||||
case 'restore':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
$context = context_course::instance($courseid);
|
||||
return new moodle_url('/backup/restorefile.php', ['contextid' => $context->id]);
|
||||
case 'reset':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/course/reset.php', ['id' => $courseid]);
|
||||
case 'course copy':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/backup/copy.php', ['id' => $courseid]);
|
||||
case 'groups':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/group/index.php', ['id' => $courseid]);
|
||||
case 'permissions':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
$context = context_course::instance($courseid);
|
||||
return new moodle_url('/admin/roles/permissions.php', ['contextid' => $context->id]);
|
||||
case 'enrolment methods':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/enrol/instances.php', ['id' => $courseid]);
|
||||
case 'enrolled users':
|
||||
$courseid = $this->get_course_id($identifier);
|
||||
if (!$courseid) {
|
||||
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
|
||||
$identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/user/index.php', ['id' => $courseid]);
|
||||
}
|
||||
|
||||
$parts = explode(' ', $type);
|
||||
|
@ -81,7 +81,12 @@ class behat_permissions extends behat_base {
|
||||
);
|
||||
|
||||
if (!$this->running_javascript()) {
|
||||
$this->execute("behat_general::i_click_on_in_the", [get_string('go'), 'button', "div.advancedoverride", 'css_element']);
|
||||
$xpath = "//div[@class='advancedoverride']/div/form/noscript";
|
||||
$this->execute("behat_general::i_click_on_in_the", [
|
||||
get_string('go'), 'button',
|
||||
$this->escape($xpath),
|
||||
'xpath_element']
|
||||
);
|
||||
}
|
||||
|
||||
$this->execute("behat_permissions::i_fill_the_capabilities_form_with_the_following_permissions", $table);
|
||||
|
Loading…
x
Reference in New Issue
Block a user