MDL-58265 core_test: add I am on course page behat step
authorSimey Lameze <simey@moodle.com>
Tue, 14 Mar 2017 04:44:23 +0000 (12:44 +0800)
committerDamyon Wiese <damyon@moodle.com>
Mon, 3 Apr 2017 03:37:07 +0000 (11:37 +0800)
Part of MDL-55611 epic.

lib/tests/behat/behat_navigation.php

index 9460ebd..00b0336 100644 (file)
@@ -574,4 +574,20 @@ class behat_navigation extends behat_base {
         $USER = $globuser;
     }
 
+    /**
+     * Opens the course page.
+     *
+     * @Given /^I am on course page "(?P<coursefullname_string>(?:[^"]|\\")*)"$/
+     * @throws coding_exception
+     * @param $coursefullname string The full name of the course.
+     * @return void
+     */
+    public function i_am_on_course_page($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()));
+    }
 }