MDL-72179 behat: Make use of page resolvers
This commit is contained in:
@@ -48,8 +48,7 @@ class behat_mod_data extends behat_base {
|
||||
* @param TableNode $fielddata
|
||||
*/
|
||||
public function i_add_a_field_to_database_and_i_fill_the_form_with($fieldtype, $activityname, TableNode $fielddata) {
|
||||
|
||||
$this->execute("behat_general::click_link", $this->escape($activityname));
|
||||
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'data activity']);
|
||||
|
||||
// Open "Fields" tab if it is not already open.
|
||||
$fieldsstr = get_string('fields', 'mod_data');
|
||||
@@ -80,11 +79,33 @@ class behat_mod_data extends behat_base {
|
||||
* @param TableNode $entrydata
|
||||
*/
|
||||
public function i_add_an_entry_to_database_with($activityname, TableNode $entrydata) {
|
||||
|
||||
$this->execute("behat_general::click_link", $this->escape($activityname));
|
||||
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration",
|
||||
get_string('add', 'mod_data'));
|
||||
|
||||
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'mod_data > add entry']);
|
||||
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $entrydata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
|
||||
*
|
||||
* Recognised page names are:
|
||||
* | pagetype | name meaning | description |
|
||||
* | Add entry | Database name | Add an entry page (view.php) |
|
||||
*
|
||||
* @param string $type identifies which type of page this is, e.g. 'Add entry'.
|
||||
* @param string $identifier identifies the particular page, e.g. 'My database name'.
|
||||
* @return moodle_url the corresponding URL.
|
||||
* @throws Exception with a meaningful error message if the specified page cannot be found.
|
||||
*/
|
||||
protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
|
||||
global $DB;
|
||||
|
||||
switch (strtolower($type)) {
|
||||
case 'add entry':
|
||||
return new moodle_url('/mod/data/edit.php', [
|
||||
'd' => $this->get_cm_by_activity_name('data', $identifier)->instance,
|
||||
]);
|
||||
|
||||
default:
|
||||
throw new Exception("Unrecognised page type '{$type}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user