From 5611053587f2c9c991f46db94bc48fdba9998818 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 3 May 2017 17:31:23 +0100 Subject: [PATCH] MDL-58788 behat: backport of course navigation with editing step --- .../behat/backported_step_definitions.feature | 17 ++++++++++++++-- lib/tests/behat/behat_navigation.php | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/admin/tool/behat/tests/behat/backported_step_definitions.feature b/admin/tool/behat/tests/behat/backported_step_definitions.feature index 4bf25377042..919dcbebb2c 100644 --- a/admin/tool/behat/tests/behat/backported_step_definitions.feature +++ b/admin/tool/behat/tests/behat/backported_step_definitions.feature @@ -15,7 +15,7 @@ Feature: Backported behat step definitions And the following "course enrolments" exist: | user | course | role | | student1 | C101 | student | - | teacher1 | C101 | teacher | + | teacher1 | C101 | editingteacher | Scenario: I am on the course homepage When I log in as "student1" @@ -23,7 +23,20 @@ Feature: Backported behat step definitions Then I should see "Topic 1" @javascript - Scenario: I am on the course homepage + Scenario: I am on the course homepage with JS When I log in as "teacher1" And I am on "Course 1" course homepage Then I should see "Topic 1" + + Scenario: I am on the course homepage with editing + When I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + Then I should see "Topic 1" + And I should see "Add an activity or resource" + + @javascript + Scenario: I am on the course homepage with editing and JS + When I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on + Then I should see "Topic 1" + And I should see "Add an activity or resource" \ No newline at end of file diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index a0c917f2859..0c270311aff 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -588,4 +588,24 @@ class behat_navigation extends behat_base { $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 string $coursefullname 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(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')]); + } + } }