diff --git a/admin/tool/behat/tests/behat/backported_step_definitions.feature b/admin/tool/behat/tests/behat/backported_step_definitions.feature new file mode 100644 index 00000000000..919dcbebb2c --- /dev/null +++ b/admin/tool/behat/tests/behat/backported_step_definitions.feature @@ -0,0 +1,42 @@ +@tool @tool_behat +Feature: Backported behat step definitions + In order to provide feature file compatibility between multiple Moodle versions + As a developer + I need to be able to use backported steps from newer Moodle versiosn + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@example.com | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C101 | topics | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C101 | student | + | teacher1 | C101 | editingteacher | + + Scenario: I am on the course homepage + When I log in as "student1" + And I am on "Course 1" course homepage + Then I should see "Topic 1" + + @javascript + 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 bab8ba1e011..67e69a4a639 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -572,4 +572,35 @@ class behat_navigation extends behat_base { // Restore global user variable. $USER = $globuser; } + + /** + * Opens the course homepage. + * + * @Given /^I am on "(?P(?:[^"]|\\")*)" course homepage$/ + * @throws coding_exception + * @param string $coursefullname The full name of the course. + * @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]); + $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))); + $this->execute("behat_forms::press_button", get_string('turneditingon')); + } } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 5d779ac636c..64772010701 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in core libraries and APIs, information provided here is intended especially for developers. +=== 3.1.6 === + +* Behat compatibility changes are now being documented at + https://docs.moodle.org/dev/Acceptance_testing/Compatibility_changes + === 3.1.5 === * get_user_capability_course() now has an additional parameter 'limit'. This can be used to return a set number of records with