Permalink
Browse files

MDL-52471 completion: fix deprecated use of 'object'

And add a unit test covering completion_can_view_data() without
full course object passed.
  • Loading branch information...
danpoltawski committed Dec 10, 2015
1 parent 88cece4 commit a3f65f8b5b3a8881114ae111768652210f54e103
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/completionlib.php
  2. +11 −0 lib/tests/completionlib_test.php
View
@@ -158,7 +158,7 @@ function completion_can_view_data($userid, $course = null) {
if (!is_object($course)) {
$cid = $course;
$course = new object();
$course = new stdClass();
$course->id = $cid;
}
@@ -858,6 +858,17 @@ public function test_course_completion_updated_event() {
$expectedlegacylog = array($this->course->id, 'course', 'completion updated', 'completion.php?id='.$this->course->id);
$this->assertEventLegacyLogData($expectedlegacylog, $event);
}
public function test_completion_can_view_data() {
$this->setup_data();
$student = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($student->id, $this->course->id);
$this->setUser($student);
$this->assertTrue(completion_can_view_data($student->id, $this->course->id));
$this->assertFalse(completion_can_view_data($this->user->id, $this->course->id));
}
}
class core_completionlib_fake_recordset implements Iterator {

0 comments on commit a3f65f8

Please sign in to comment.