From a4c2860ea34897cc914a6afcf28078f681031dd2 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Sun, 8 Dec 2024 10:10:24 +0100 Subject: [PATCH] Upgrade: Adopt changes from MDL-81960 to Behat optimizations and use new \core\url class there as well --- CHANGES.md | 1 + tests/behat/behat_theme_boost_union.php | 34 +++++++++++++------------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6bc3a321150..4da515fef14 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2024-12-08 - Upgrade: Adopt changes from MDL-81960 to Behat optimizations and use new \core\url class there as well. * 2024-12-06 - Tests: Add several Behat optimisations to bring down the test suite run time, resolves #765. * 2024-12-06 - Upstream change: Adopt changes from MDL-83759 ('System notification navbar popover is misplaced in Moodle 4.4 and 4.5') * 2024-12-06 - Upstream change: Adopt changes from MDL-75610 ('Quiz activity name no longer being displayed in quiz landing page when using Safe Exam Browser'), resolves #766. diff --git a/tests/behat/behat_theme_boost_union.php b/tests/behat/behat_theme_boost_union.php index 5139ec649a4..f13a4a6f673 100644 --- a/tests/behat/behat_theme_boost_union.php +++ b/tests/behat/behat_theme_boost_union.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +use core\url; + /** * Theme Boost Union - Standard behat step data providers. * @@ -38,21 +40,21 @@ class behat_theme_boost_union extends behat_base { * | Smart menus | Smart menus listing page | * * @param string $page name of the page, with the component name removed e.g. 'Admin notification'. - * @return moodle_url the corresponding URL. + * @return 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 { + protected function resolve_page_url(string $page): url { $parts = explode('>', strtolower($page)); $section = trim($parts[0]); if (count($parts) < 2) { return match ($section) { - 'settings' => new moodle_url('/theme/boost_union/settings_overview.php'), - 'look' => new moodle_url('/admin/settings.php?section=theme_boost_union_look'), - 'feel' => new moodle_url('/admin/settings.php?section=theme_boost_union_feel'), - 'content' => new moodle_url('/admin/settings.php?section=theme_boost_union_content'), - 'functionality' => new moodle_url('/admin/settings.php?section=theme_boost_union_functionality'), - 'flavours' => new moodle_url('/theme/boost_union/flavours/overview.php'), - 'smart menus' => new moodle_url('/theme/boost_union/smartmenus/menus.php'), + 'settings' => new url('/theme/boost_union/settings_overview.php'), + 'look' => new url('/admin/settings.php?section=theme_boost_union_look'), + 'feel' => new url('/admin/settings.php?section=theme_boost_union_feel'), + 'content' => new url('/admin/settings.php?section=theme_boost_union_content'), + 'functionality' => new url('/admin/settings.php?section=theme_boost_union_functionality'), + 'flavours' => new url('/theme/boost_union/flavours/overview.php'), + 'smart menus' => new url('/theme/boost_union/smartmenus/menus.php'), default => throw new Exception('Unrecognised theme_boost_union page "' . $page . '."') }; } @@ -129,7 +131,7 @@ protected function resolve_page_url(string $page): moodle_url { if (!in_array($suffix, $tabs)) { throw new Exception('Unrecognised theme_boost_union page "' . $page . '."'); } - return new moodle_url('/admin/settings.php?section=theme_boost_union_' . $section . '_' . $suffix); + return new url('/admin/settings.php?section=theme_boost_union_' . $section . '_' . $suffix); } /** @@ -146,10 +148,10 @@ protected function resolve_page_url(string $page): moodle_url { * * @param string $type identifies which type of page this is, e.g. 'Smart menu item'. * @param string $identifier identifies the particular page, e.g. 'Menu 1 > Item 1'. - * @return moodle_url the corresponding URL. + * @return 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 { + protected function resolve_page_instance_url(string $type, string $identifier): url { $parts = explode('>', strtolower($type)); $pagetype = trim($parts[0]); @@ -159,7 +161,7 @@ protected function resolve_page_instance_url(string $type, string $identifier): if (!in_array($page, ['preview', 'edit'])) { throw new Exception('Unrecognised theme_boost_union page type "' . $type . '."'); } - return new moodle_url( + return new url( '/theme/boost_union/flavours/' . $page . '.php', [ 'id' => $this->get_flavour_id_by_title($identifier), @@ -173,7 +175,7 @@ protected function resolve_page_instance_url(string $type, string $identifier): throw new Exception('Unrecognised theme_boost_union page type "' . $type . '."'); } $idparam = $page == 'edit' ? 'id' : 'menu'; - return new moodle_url( + return new url( '/theme/boost_union/smartmenus/' . $page . '.php', [ $idparam => $this->get_smartmenu_id_by_title($identifier), @@ -186,7 +188,7 @@ protected function resolve_page_instance_url(string $type, string $identifier): $menutitle = trim($idparts[0]); $itemtitle = trim($idparts[1]); $menuid = $this->get_smartmenu_id_by_title($menutitle); - return new moodle_url( + return new url( '/theme/boost_union/smartmenus/edit_items.php', [ 'id' => $this->get_smartmenu_item_id_by_title($menuid, $itemtitle), @@ -195,7 +197,7 @@ protected function resolve_page_instance_url(string $type, string $identifier): ); case 'course completion': - return new moodle_url( + return new url( '/course/completion.php', [ 'id' => $this->get_course_id($identifier),