Skip to content

Commit

Permalink
MDL-43440 unit tests Use correct cm identifier in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
micaherne authored and mr-russ committed Jan 24, 2014
1 parent 9788e26 commit 780cf0a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion grade/tests/edittreelib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function test_grade_edit_tree_column_range_get_item_cell() {
$scale = $this->getDataGenerator()->create_scale();
$course = $this->getDataGenerator()->create_course();
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course->id));
$modulecontext = context_module::instance($assign->id);
$modulecontext = context_module::instance($assign->cmid);
// The generator returns a dummy object, lets get the real assign object.
$assign = new assign($modulecontext, false, false);
$cm = $assign->get_course_module();
Expand Down
2 changes: 1 addition & 1 deletion grade/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function test_get_gradingform_instances() {
// Create a teacher and give them capabilities.
$coursecontext = context_course::instance($course->id);
$roleid = $this->assignUserCapability('moodle/course:viewparticipants', $coursecontext->id, 3);
$modulecontext = context_module::instance($assign->id);
$modulecontext = context_module::instance($assign->cmid);
$this->assignUserCapability('mod/assign:grade', $modulecontext->id, $roleid);

// Create the teacher's enrolment record.
Expand Down
6 changes: 3 additions & 3 deletions lib/tests/messagelib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function test_message_get_providers_for_user_more() {
// however mod_quiz doesn't have a data generator.
// Instead we're going to use backup notifications and give and take away the capability at various levels.
$assign = $this->getDataGenerator()->create_module('assign', array('course'=>$course->id));
$modulecontext = context_module::instance($assign->id);
$modulecontext = context_module::instance($assign->cmid);

// Create and enrol a teacher.
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
Expand Down Expand Up @@ -162,7 +162,7 @@ public function test_message_get_providers_for_user_more() {
// They should now be able to see the backup message.
assign_capability('moodle/site:config', CAP_ALLOW, $teacherrole->id, $modulecontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$modulecontext = context_module::instance($assign->id);
$modulecontext = context_module::instance($assign->cmid);
$this->assertTrue(has_capability('moodle/site:config', $modulecontext));

$providers = message_get_providers_for_user($teacher->id);
Expand All @@ -173,7 +173,7 @@ public function test_message_get_providers_for_user_more() {
// They should not be able to see the backup message.
assign_capability('moodle/site:config', CAP_PROHIBIT, $teacherrole->id, $coursecontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$modulecontext = context_module::instance($assign->id);
$modulecontext = context_module::instance($assign->cmid);
$this->assertFalse(has_capability('moodle/site:config', $modulecontext));

$providers = message_get_providers_for_user($teacher->id);
Expand Down
8 changes: 4 additions & 4 deletions mod/assign/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function test_get_grades() {
// Create a teacher and give them capabilities.
$context = context_course::instance($course->id);
$roleid = $this->assignUserCapability('moodle/course:viewparticipants', $context->id, 3);
$context = context_module::instance($assign->id);
$context = context_module::instance($assign->cmid);
$this->assignUserCapability('mod/assign:grade', $context->id, $roleid);

// Create the teacher's enrolment record.
Expand Down Expand Up @@ -332,7 +332,7 @@ public function test_get_user_flags() {
// Create a teacher and give them capabilities.
$context = context_course::instance($course->id);
$roleid = $this->assignUserCapability('moodle/course:viewparticipants', $context->id, 3);
$context = context_module::instance($assign->id);
$context = context_module::instance($assign->cmid);
$this->assignUserCapability('mod/assign:grade', $context->id, $roleid);

// Create the teacher's enrolment record.
Expand Down Expand Up @@ -403,7 +403,7 @@ public function test_get_user_mappings() {
// Create a teacher and give them capabilities.
$context = context_course::instance($course->id);
$roleid = $this->assignUserCapability('moodle/course:viewparticipants', $context->id, 3);
$context = context_module::instance($assign->id);
$context = context_module::instance($assign->cmid);
$this->assignUserCapability('mod/assign:revealidentities', $context->id, $roleid);

// Create the teacher's enrolment record.
Expand Down Expand Up @@ -1072,7 +1072,7 @@ public function test_set_user_flags() {
// Create a teacher and give them capabilities.
$context = context_course::instance($course->id);
$roleid = $this->assignUserCapability('moodle/course:viewparticipants', $context->id, 3);
$context = context_module::instance($assign->id);
$context = context_module::instance($assign->cmid);
$this->assignUserCapability('mod/assign:grade', $context->id, $roleid);

// Create the teacher's enrolment record.
Expand Down
4 changes: 2 additions & 2 deletions repository/tests/repositorylib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ public function test_check_capability() {
$forumdata = new stdClass();
$forumdata->course = $course1->id;
$forumc1 = $this->getDataGenerator()->create_module('forum', $forumdata);
$forumc1context = context_module::instance($forumc1->id);
$forumc1context = context_module::instance($forumc1->cmid);
$forumdata->course = $course2->id;
$forumc2 = $this->getDataGenerator()->create_module('forum', $forumdata);
$forumc2context = context_module::instance($forumc2->id);
$forumc2context = context_module::instance($forumc2->cmid);

$blockdata = new stdClass();
$blockdata->parentcontextid = $course1context->id;
Expand Down

0 comments on commit 780cf0a

Please sign in to comment.