Skip to content

Commit

Permalink
Merge branch 'MDL-68492-master' of https://github.com/sammarshallou/m…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 1, 2020
2 parents ce8cc79 + 111cf93 commit 3076dfe
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 54 deletions.
8 changes: 2 additions & 6 deletions lib/tests/behat/action_modal.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ Feature: Close modals by clicking outside them
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| quiz | Test quiz name | Test quiz description | C1 | quiz1 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And I am on the "quiz1" "Activity" page logged in as "admin"
And I click on "Edit quiz" "button"
And I click on "Add" "link"
And I click on "a new question" "link"
Expand Down Expand Up @@ -43,9 +41,7 @@ Feature: Close modals by clicking outside them
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| quiz | Test quiz name | Test quiz description | C1 | quiz1 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And I am on the "quiz1" "Activity" page logged in as "admin"
And I click on "Edit quiz" "button"
And I click on "Help with Editing quiz" "icon"
And I should see "More help"
Expand Down
30 changes: 9 additions & 21 deletions lib/tests/behat/alpha_chooser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ Feature: Initials bar
Given the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled |
| assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 |
And I log in as "teacher"
And I am on "Course 1" course homepage
And I follow "TestAssignment"
And I am on the "assign1" "Activity" page logged in as "teacher"
When I navigate to "View all submissions" in current page administration
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element"
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.lastinitial" "css_element"
Expand All @@ -95,8 +93,7 @@ Feature: Initials bar
And I should not see "Astudent Astudent"
And I should see "Bstudent Astudent"
And I should not see "Cstudent Cstudent"
And I am on "Course 1" course homepage
And I follow "TestAssignment"
And I am on the "assign1" "Activity" page
When I navigate to "View all submissions" in current page administration
And ".initialbarall.page-item.active" "css_element" should not exist in the ".initialbar.firstinitial" "css_element"
And ".initialbarall.page-item.active" "css_element" should not exist in the ".initialbar.lastinitial" "css_element"
Expand Down Expand Up @@ -126,9 +123,7 @@ Feature: Initials bar
Given the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled |
| assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 |
And I log in as "teacher"
And I am on "Course 1" course homepage
And I follow "TestAssignment"
And I am on the "assign1" "Activity" page logged in as "teacher"
When I navigate to "View all submissions" in current page administration
And I select "View gradebook" from the "jump" singleselect
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element"
Expand All @@ -154,8 +149,7 @@ Feature: Initials bar
And I should not see "Astudent Astudent"
And I should see "Bstudent Astudent"
And I should not see "Cstudent Cstudent"
And I am on "Course 1" course homepage
And I follow "TestAssignment"
And I am on the "assign1" "Activity" page
When I navigate to "View all submissions" in current page administration
And I select "View gradebook" from the "jump" singleselect
And ".initialbarall.page-item.active" "css_element" should not exist in the ".initialbar.firstinitial" "css_element"
Expand Down Expand Up @@ -186,14 +180,11 @@ Feature: Initials bar
Given the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled |
| assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 |
And I log in as "student1"
And I am on "Course 1" course homepage
And I am on the "C1" "Course" page logged in as "student1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I am on the "C1" "Course" page logged in as "student2"
And I log out
And I log in as "teacher"
And I am on "Course 1" course homepage
And I am on the "C1" "Course" page logged in as "teacher"
And I follow "Participants"
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element"
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.lastinitial" "css_element"
Expand Down Expand Up @@ -249,9 +240,7 @@ Feature: Initials bar
Given the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled |
| assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "TestAssignment"
And I am on the "assign1" "Activity" page logged in as "admin"
And I navigate to "Edit settings" in current page administration
And I expand all fieldsets
And I set the field "Completion tracking" to "1"
Expand All @@ -261,8 +250,7 @@ Feature: Initials bar
And I click on "Assignment - TestAssignment" "checkbox"
And I click on "Save changes" "button"
And I log out
And I log in as "teacher"
And I am on "Course 1" course homepage
And I am on the "C1" "Course" page logged in as "teacher"
And I navigate to "Reports > Activity completion" in current page administration
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element"
And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.lastinitial" "css_element"
Expand Down
20 changes: 19 additions & 1 deletion lib/tests/behat/behat_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ protected function resolve_core_page_url(string $name): moodle_url {
* Recognised page names are:
* | Page type | Identifier meaning | description |
* | Category page | category idnumber | List of courses in that category. |
* | Course | course shortname | Main course home pag |
* | Activity | activity idnumber | Start page for that activity |
*
* @param string $type identifies which type of page this is, e.g. 'Category page'.
* @param string $identifier identifies the particular page, e.g. 'test-cat'.
Expand All @@ -718,13 +720,29 @@ protected function resolve_core_page_instance_url(string $type, string $identifi
}
return new moodle_url('/course/category.php', ['id' => $categoryid]);

case 'Course':
$courseid = $DB->get_field_select('course', 'id', 'shortname = ?', [$identifier], IGNORE_MISSING);
if (!$courseid) {
throw new Exception('The specified course with shortname, fullname, or idnumber "' .
$identifier . '" does not exist');
}
return new moodle_url('/course/view.php', ['id' => $courseid]);

case 'Activity':
$cm = $DB->get_record('course_modules', ['idnumber' => $identifier], 'id, course', IGNORE_MISSING);
if (!$cm) {
throw new Exception('The specified activity with idnumber "' . $identifier . '" does not exist');
}
$modinfo = get_fast_modinfo($cm->course);
return $modinfo->cms[$cm->id]->url;

default:
throw new Exception('Unrecognised core page type "' . $type . '."');
}
}

/**
* Opens the course homepage.
* Opens the course homepage. (Consider using 'I am on the "shortname" "Course" page' step instead.)
*
* @Given /^I am on "(?P<coursefullname_string>(?:[^"]|\\")*)" course homepage$/
* @throws coding_exception
Expand Down
3 changes: 1 addition & 2 deletions lib/tests/behat/largeforms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Feature: Forms with a large number of fields
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/tests/fixtures/max_input_vars.php">FixtureLink</a> | C1 | label1 |
When I log in as "admin"
And I am on "Course 1" course homepage
When I am on the "C1" "Course" page logged in as "admin"
And I follow "FixtureLink"

# Note: These tests do not actually use JavaScript but they don't work with
Expand Down
24 changes: 8 additions & 16 deletions lib/tests/behat/locking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Feature: Context freezing apply to child contexts
| student1 | courseb | student |

Scenario: Freeze course module module should freeze just that module
Given I log in as "admin"
And I am on "courseaa1" course homepage
Given I am on the "courseaa1" "Course" page logged in as "admin"
And I follow "faa1"
And "Add a new discussion topic" "link" should exist
When I follow "Freeze this context"
Expand All @@ -58,8 +57,7 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should exist

And I log out
When I log in as "teacher"
And I am on "courseaa1" course homepage
When I am on the "courseaa1" "Course" page logged in as "teacher"
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Expand All @@ -76,8 +74,7 @@ Feature: Context freezing apply to child contexts
And "Add a new discussion topic" "link" should exist

And I log out
When I log in as "student1"
And I am on "courseaa1" course homepage
When I am on the "courseaa1" "Course" page logged in as "student1"
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Expand All @@ -91,8 +88,7 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should exist

Scenario: Freeze course should freeze all children
Given I log in as "admin"
And I am on "courseaa1" course homepage
Given I am on the "courseaa1" "Course" page logged in as "admin"
And I should see "Turn editing on"
When I follow "Freeze this context"
And I click on "Continue" "button"
Expand All @@ -114,8 +110,7 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should exist

And I log out
When I log in as "teacher"
And I am on "courseaa1" course homepage
When I am on the "courseaa1" "Course" page logged in as "teacher"
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Expand All @@ -132,8 +127,7 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should exist

And I log out
When I log in as "student1"
And I am on "courseaa1" course homepage
When I am on the "courseaa1" "Course" page logged in as "student1"
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Expand Down Expand Up @@ -171,8 +165,7 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should exist

And I log out
When I log in as "teacher"
And I am on "courseaa1" course homepage
When I am on the "courseaa1" "Course" page logged in as "teacher"
Then I should not see "Turn editing on"
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
Expand All @@ -190,8 +183,7 @@ Feature: Context freezing apply to child contexts
Then "Add a new discussion topic" "link" should exist

And I log out
When I log in as "student1"
And I am on "courseaa1" course homepage
When I am on the "courseaa1" "Course" page logged in as "student1"
And I follow "faa1"
Then "Add a new discussion topic" "link" should not exist
When I am on "courseaa1" course homepage
Expand Down
3 changes: 1 addition & 2 deletions lib/tests/behat/permissionmanager.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Feature: Override permissions on a context
| teacher1 | C1 | editingteacher |

Scenario: Default system capabilities modification
Given I log in as "admin"
And I am on "Course 1" course homepage
Given I am on the "C1" "Course" page logged in as "admin"
And I navigate to "Users > Permissions" in current page administration
When I click on "Allow" "icon" in the "mod/forum:addnews" "table_row"
And I press "Student"
Expand Down
6 changes: 2 additions & 4 deletions lib/tests/behat/readonlyform.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Feature: Read-only forms should work
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/tests/fixtures/readonlyform.php?sections=1">Fixture link</a> | C1 | label1 |
And I log in as "admin"
And I am on "Course 1" course homepage
Given I am on the "C1" "Course" page logged in as "admin"
And I follow "Fixture link"
When I expand all fieldsets
Then the field "Name" matches value "Important information"
Expand All @@ -26,8 +25,7 @@ Feature: Read-only forms should work
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/tests/fixtures/readonlyform.php?sections=2">Fixture link</a> | C1 | label1 |
And I log in as "admin"
And I am on "Course 1" course homepage
Given I am on the "C1" "Course" page logged in as "admin"
And I follow "Fixture link"
When I expand all fieldsets
Then the field "Name" matches value "Important information"
Expand Down
3 changes: 1 addition & 2 deletions lib/tests/behat/securelayout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Feature: Page displaying with secure layout
| label | L1 | <a href="../lib/tests/fixtures/securetestpage.php">Fixture link</a> | C1 | label1 |

Scenario: Confirm that there is no header link
Given I log in as "admin"
And I am on "Course 1" course homepage
Given I am on the "C1" "Course" page logged in as "admin"
When I follow "Fixture link"
Then I should see "Acceptance test site" in the "nav" "css_element"
But "Acceptance test site" "link" should not exist

0 comments on commit 3076dfe

Please sign in to comment.