MDL-43738 behat: New step to adapt to radio buttons behaviour
Now we interact with radio fields through it's value or text.
This commit is contained in:
@@ -90,10 +90,10 @@ Feature: Set up contextual data for tests
|
||||
And I expand "Users" node
|
||||
And I follow "Permissions"
|
||||
And I select "Student (1)" from "Advanced role override"
|
||||
Then the "mod/forum:editanypost" field should match "1" value
|
||||
Then "mod/forum:editanypost" capability has "Allow" permission
|
||||
And I press "Cancel"
|
||||
And I select "Teacher (1)" from "Advanced role override"
|
||||
And the "mod/forum:replynews" field should match "-1" value
|
||||
And "mod/forum:replynews" capability has "Prevent" permission
|
||||
And I press "Cancel"
|
||||
|
||||
Scenario: Add course enrolments
|
||||
|
||||
@@ -25,10 +25,10 @@ Feature: Edit capabilities
|
||||
| moodle/grade:managesharedforms | Prevent |
|
||||
| moodle/course:request | Prohibit |
|
||||
When I follow "Edit Teacher role"
|
||||
Then the "block/mnet_hosts:myaddinstance" field should match "1" value
|
||||
And the "moodle/community:add" field should match "0" value
|
||||
And the "moodle/grade:managesharedforms" field should match "-1" value
|
||||
And the "moodle/course:request" field should match "-1000" value
|
||||
Then "block/mnet_hosts:myaddinstance" capability has "Allow" permission
|
||||
And "moodle/community:add" capability has "Not set" permission
|
||||
And "moodle/grade:managesharedforms" capability has "Prevent" permission
|
||||
And "moodle/course:request" capability has "Prohibit" permission
|
||||
|
||||
@javascript
|
||||
Scenario: Course capabilities overrides
|
||||
@@ -41,9 +41,9 @@ Feature: Edit capabilities
|
||||
| mod/forum:editanypost | Prevent |
|
||||
| mod/forum:addquestion | Allow |
|
||||
When I select "Student (3)" from "Advanced role override"
|
||||
Then the "mod/forum:deleteanypost" field should match "-1000" value
|
||||
And the "mod/forum:editanypost" field should match "-1" value
|
||||
And the "mod/forum:addquestion" field should match "1" value
|
||||
Then "mod/forum:deleteanypost" capability has "Prohibit" permission
|
||||
And "mod/forum:editanypost" capability has "Prevent" permission
|
||||
And "mod/forum:addquestion" capability has "Allow" permission
|
||||
|
||||
@javascript
|
||||
Scenario: Module capabilities overrides
|
||||
@@ -60,6 +60,6 @@ Feature: Edit capabilities
|
||||
| mod/forum:editanypost | Prevent |
|
||||
| mod/forum:addquestion | Allow |
|
||||
When I select "Student (3)" from "Advanced role override"
|
||||
Then the "mod/forum:deleteanypost" field should match "-1000" value
|
||||
And the "mod/forum:editanypost" field should match "-1" value
|
||||
And the "mod/forum:addquestion" field should match "1" value
|
||||
Then "mod/forum:deleteanypost" capability has "Prohibit" permission
|
||||
And "mod/forum:editanypost" capability has "Prevent" permission
|
||||
And "mod/forum:addquestion" capability has "Allow" permission
|
||||
|
||||
@@ -299,13 +299,13 @@ class behat_data_generators extends behat_base {
|
||||
$context = $this->get_context($data['contextlevel'], $data['reference']);
|
||||
|
||||
switch ($data['permission']) {
|
||||
case self::cap_allow:
|
||||
case get_string('allow', 'role'):
|
||||
$permission = CAP_ALLOW;
|
||||
break;
|
||||
case self::cap_prevent:
|
||||
case get_string('prevent', 'role'):
|
||||
$permission = CAP_PREVENT;
|
||||
break;
|
||||
case self::cap_prohibit:
|
||||
case get_string('prohibit', 'role'):
|
||||
$permission = CAP_PROHIBIT;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -142,4 +142,44 @@ class behat_permissions extends behat_base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the capability has the specified permission. Works in the role definition advanced page.
|
||||
*
|
||||
* @Then /^"(?P<capability_string>(?:[^"]|\\")*)" capability has "(?P<permission_string>Not set|Allow|Prevent|Prohibit)" permission$/
|
||||
* @throws ExpectationException
|
||||
* @param string $capabilityname
|
||||
* @param string $permission
|
||||
* @return void
|
||||
*/
|
||||
public function capability_has_permission($capabilityname, $permission) {
|
||||
|
||||
// We already know the name, so we just need the value.
|
||||
$radioxpath = "//table[@class='rolecap']/descendant::input[@type='radio']" .
|
||||
"[@name='" . $capabilityname . "'][@checked]";
|
||||
|
||||
$checkedradio = $this->find('xpath', $radioxpath);
|
||||
|
||||
switch ($permission) {
|
||||
case get_string('notset', 'role'):
|
||||
$perm = CAP_INHERIT;
|
||||
break;
|
||||
case get_string('allow', 'role'):
|
||||
$perm = CAP_ALLOW;
|
||||
break;
|
||||
case get_string('prevent', 'role'):
|
||||
$perm = CAP_PREVENT;
|
||||
break;
|
||||
case get_string('prohibit', 'role'):
|
||||
$perm = CAP_PROHIBIT;
|
||||
break;
|
||||
default:
|
||||
throw new ExpectationException('"' . $permission . '" permission does not exist', $this->getSession());
|
||||
break;
|
||||
}
|
||||
|
||||
if ($checkedradio->getAttribute('value') != $perm) {
|
||||
throw new ExpectationException('"' . $capabilityname . '" permission is not "' . $permission . '"', $this->getSession());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user