MDL-74643 core_user: Added behat page resolver

Currently this supports resolving the Contact Site Support page.
This commit is contained in:
Michael Hawkins 2022-10-15 00:37:29 +08:00
parent fa7a55aa5d
commit ddc9a30fa1

View File

@ -84,4 +84,26 @@ class behat_user extends behat_base {
throw new ExpectationException('The "' . $field . '" field does have purpose "' . $purpose . '"', $this->getSession());
}
}
/**
* Convert page names to URLs for steps like 'When I am on the "[page name]" page'.
*
* Recognised page names are:
* | Page name | Description |
* | Contact Site Support | The Contact Site Support page (user/contactsitesupport.php) |
*
* @param string $page name of the page, with the component name removed e.g. 'Admin notification'.
* @return moodle_url the corresponding URL.
* @throws Exception with a meaningful error message if the specified page cannot be found.
*/
protected function resolve_page_url(string $page): moodle_url {
switch (strtolower($page)) {
case 'contact site support':
return new moodle_url('/user/contactsitesupport.php');
default:
throw new Exception("Unrecognised core_user page type '{$page}'.");
}
}
}