Skip to content

Commit

Permalink
MDL-72179 behat: Add page resolvers for activity roles/perms
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 23, 2021
1 parent 950c7ad commit f14dbe0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion admin/tool/behat/tests/behat/i_am_on_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Feature: Use core page resolvers for the I am on the page steps
Then I should see "<shouldsee>"

Examples:
| description | identifier | type | shouldsee |
| Course Category idnumber | CAT1 | category | Add a new course |
| Course Category name | "Cat 1" | Category | Add a new course |
| Course Full name | "Economics 101" | course | Fundamentals of Economics |
Expand All @@ -31,6 +32,8 @@ Feature: Use core page resolvers for the I am on the page steps
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
| Forum name | "Fundamentals of Economics" | "Forum activity" | Add a new discussion |
| Forum name editing | "Fundamentals of Economics" | "Forum activity editing" | Updating: Forum |
| Forum name permissions | "Fundamentals of Economics" | "Forum activity permissions" | Permissions in Forum: Fun |
| Forum name roles | "Fundamentals of Economics" | "Forum activity roles" | Assign roles in Forum: Fun |

Scenario Outline: When I am on an instance logged in as
Given the following "categories" exist:
Expand All @@ -49,7 +52,7 @@ Feature: Use core page resolvers for the I am on the page steps
Then I should see "<shouldsee>"

Examples:
| description | identifier | type | shouldsee |
| description | identifier | type | shouldsee |
| Course Category idnumber | CAT1 | category | Add a new course |
| Course Category name | "Cat 1" | Category | Add a new course |
| Course Full name | "Economics 101" | course | Fundamentals of Economics |
Expand All @@ -59,6 +62,8 @@ Feature: Use core page resolvers for the I am on the page steps
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
| Forum name | "Fundamentals of Economics" | "Forum activity" | Add a new discussion |
| Forum name editing | "Fundamentals of Economics" | "Forum activity editing" | Updating: Forum |
| Forum name permissions | "Fundamentals of Economics" | "Forum activity permissions" | Permissions in Forum: Fun |
| Forum name roles | "Fundamentals of Economics" | "Forum activity roles" | Assign roles in Forum: Fun |

Scenario Outline: When I am on a named page
Given I log in as "admin"
Expand Down
12 changes: 12 additions & 0 deletions lib/tests/behat/behat_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,12 +777,24 @@ protected function resolve_core_page_instance_url(string $type, string $identifi
$cm = $this->get_cm_by_activity_name($modname, $identifier);

if (count($parts) == 2) {
// View page.
return new moodle_url($cm->url);
}

if ($parts[2] === 'editing') {
// Edit settings page.
return new moodle_url('/course/modedit.php', ['update' => $cm->id]);
}

if ($parts[2] === 'roles') {
// Locally assigned roles page.
return new moodle_url('/admin/roles/assign.php', ['contextid' => $cm->context->id]);
}

if ($parts[2] === 'permissions') {
// Permissions page.
return new moodle_url('/admin/roles/permissions.php', ['contextid' => $cm->context->id]);
}
}
}

Expand Down

0 comments on commit f14dbe0

Please sign in to comment.