Skip to content

Commit

Permalink
MDL-45148 unit testing: pass role id instead of user id
Browse files Browse the repository at this point in the history
  • Loading branch information
mackensen committed Apr 17, 2014
1 parent 1131095 commit 2f9c7f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/tests/accesslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ public function test_get_assignable_roles() {
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
$teacher = $this->getDataGenerator()->create_user();
role_assign($teacherrole->id, $teacher->id, $coursecontext);
$teacherename = (object)array('roleid'=>$teacher->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
$teacherename = (object)array('roleid'=>$teacherrole->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
$DB->insert_record('role_names', $teacherename);

$studentrole = $DB->get_record('role', array('shortname'=>'student'), '*', MUST_EXIST);
Expand Down Expand Up @@ -1142,7 +1142,7 @@ public function test_get_switchable_roles() {
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
$teacher = $this->getDataGenerator()->create_user();
role_assign($teacherrole->id, $teacher->id, $coursecontext);
$teacherename = (object)array('roleid'=>$teacher->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
$teacherename = (object)array('roleid'=>$teacherrole->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
$DB->insert_record('role_names', $teacherename);

$contexts = $DB->get_records('context');
Expand Down Expand Up @@ -1200,10 +1200,10 @@ public function test_get_overridable_roles() {
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
$teacher = $this->getDataGenerator()->create_user();
role_assign($teacherrole->id, $teacher->id, $coursecontext);
$teacherename = (object)array('roleid'=>$teacher->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
$teacherename = (object)array('roleid'=>$teacherrole->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
$DB->insert_record('role_names', $teacherename);
$this->assertTrue($DB->record_exists('capabilities', array('name'=>'moodle/backup:backupcourse'))); // Any capability is ok.
assign_capability('moodle/backup:backupcourse', CAP_PROHIBIT, $teacher->id, $coursecontext->id);
assign_capability('moodle/backup:backupcourse', CAP_PROHIBIT, $teacherrole->id, $coursecontext->id);

$studentrole = $DB->get_record('role', array('shortname'=>'student'), '*', MUST_EXIST);
$student = $this->getDataGenerator()->create_user();
Expand Down

0 comments on commit 2f9c7f4

Please sign in to comment.