From c696306936da2a5ec70d0349789bc001505b55b9 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 2 Mar 2023 11:05:54 +0800 Subject: [PATCH] MDL-77461 behat: Use get_course_id instead of DB fetch --- lib/tests/behat/behat_navigation.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index 71e157726fe..7d855778fd5 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -734,8 +734,6 @@ class behat_navigation extends behat_base { * @throws Exception with a meaningful error message if the specified page cannot be found. */ protected function resolve_core_page_instance_url(string $type, string $identifier): moodle_url { - global $DB; - $type = strtolower($type); switch ($type) { @@ -819,9 +817,8 @@ class behat_navigation extends behat_base { * @return void */ public function i_am_on_course_homepage($coursefullname) { - global $DB; - $course = $DB->get_record("course", array("fullname" => $coursefullname), 'id', MUST_EXIST); - $url = new moodle_url('/course/view.php', ['id' => $course->id]); + $courseid = $this->get_course_id($coursefullname); + $url = new moodle_url('/course/view.php', ['id' => $courseid]); $this->execute('behat_general::i_visit', [$url]); } @@ -834,10 +831,8 @@ class behat_navigation extends behat_base { * @return void */ public function i_am_on_course_homepage_with_editing_mode_on($coursefullname) { - global $DB; - - $course = $DB->get_record("course", array("fullname" => $coursefullname), 'id', MUST_EXIST); - $url = new moodle_url('/course/view.php', ['id' => $course->id]); + $courseid = $this->get_course_id($coursefullname); + $url = new moodle_url('/course/view.php', ['id' => $courseid]); if ($this->running_javascript() && $sesskey = $this->get_sesskey()) { // Javascript is running so it is possible to grab the session ket and jump straight to editing mode.