MDL-38863 behat: Role assign generator
This commit is contained in:
@@ -712,6 +712,34 @@ EOD;
|
||||
$plugin->enrol_user($instance, $userid, $roleid, $timestart, $timeend, $status);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the specified role to a user in the context.
|
||||
*
|
||||
* @param int $roleid
|
||||
* @param int $userid
|
||||
* @param int $contextid Defaults to the system context
|
||||
* @return int new/existing id of the assignment
|
||||
*/
|
||||
public function role_assign($roleid, $userid, $contextid = false) {
|
||||
|
||||
// Default to the system context.
|
||||
if (!$contextid) {
|
||||
$context = context_system::instance();
|
||||
$contextid = $context->id;
|
||||
}
|
||||
|
||||
if (empty($roleid)) {
|
||||
throw new coding_exception('roleid must be present in testing_data_generator::role_assign() arguments');
|
||||
}
|
||||
|
||||
if (empty($userid)) {
|
||||
throw new coding_exception('userid must be present in testing_data_generator::role_assign() arguments');
|
||||
}
|
||||
|
||||
return role_assign($roleid, $userid, $contextid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user