mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-52471 completion: fix deprecated use of 'object'
And add a unit test covering completion_can_view_data() without full course object passed.
This commit is contained in:
parent
8440c780bd
commit
194a02e409
@ -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 @@ class core_completionlib_testcase extends advanced_testcase {
|
||||
$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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user