From 3353cfd8c1f0466eb117fc2aa9ce7095bb9952bf Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 15 Mar 2017 10:56:34 +0800 Subject: [PATCH] MDL-58265 core_test: add I am on course homepage in edit mode step This commit also: - Rename i_am_on_course_page to i_am_on_course_homepage. - Pass false to out_as_local_url() Part of MDL-55611 epic. --- lib/tests/behat/behat_navigation.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index 00b0336281b..cd85e1ebb5e 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -575,19 +575,37 @@ class behat_navigation extends behat_base { } /** - * Opens the course page. + * Opens the course homepage. * - * @Given /^I am on course page "(?P(?:[^"]|\\")*)"$/ + * @Given /^I am on "(?P(?:[^"]|\\")*)" course homepage$/ * @throws coding_exception * @param $coursefullname string The full name of the course. * @return void */ - public function i_am_on_course_page($coursefullname) { + 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]); + $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + } + /** + * Opens the course homepage with editing mode on. + * + * @Given /^I am on "(?P(?:[^"]|\\")*)" course homepage with editing mode on$/ + * @throws coding_exception + * @param $coursefullname string The course full name of the course. + * @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]); - $this->getSession()->visit($this->locate_path($url->out_as_local_url())); + $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + try { + $this->execute("behat_forms::press_button", get_string('turneditingon')); + } catch (Exception $e) { + $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", [get_string('turneditingon')]); + } } } -- 2.43.0