~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to enrol/tests/enrollib_test.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-09-09 15:22:35 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130909152235-d9njbvgugzm380an
Tags: 2.5.2-1
* New upstream version: 2.5.2.
  - Incorporates S3 security patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
250
250
        $this->assertTrue(enrol_user_sees_own_courses());
251
251
        $this->assertEquals($reads, $DB->perf_get_reads());
252
252
    }
 
253
 
 
254
    public function test_enrol_get_shared_courses() {
 
255
        $this->resetAfterTest();
 
256
 
 
257
        $user1 = $this->getDataGenerator()->create_user();
 
258
        $user2 = $this->getDataGenerator()->create_user();
 
259
        $user3 = $this->getDataGenerator()->create_user();
 
260
 
 
261
        $course1 = $this->getDataGenerator()->create_course();
 
262
        $this->getDataGenerator()->enrol_user($user1->id, $course1->id);
 
263
        $this->getDataGenerator()->enrol_user($user2->id, $course1->id);
 
264
 
 
265
        $course2 = $this->getDataGenerator()->create_course();
 
266
        $this->getDataGenerator()->enrol_user($user1->id, $course2->id);
 
267
 
 
268
        // Test that user1 and user2 have courses in common.
 
269
        $this->assertTrue(enrol_get_shared_courses($user1, $user2, false, true));
 
270
        // Test that user1 and user3 have no courses in common.
 
271
        $this->assertFalse(enrol_get_shared_courses($user1, $user3, false, true));
 
272
 
 
273
        // Test retrieving the courses in common.
 
274
        $sharedcourses = enrol_get_shared_courses($user1, $user2, true);
 
275
 
 
276
        // Only should be one shared course.
 
277
        $this->assertCount(1, $sharedcourses);
 
278
        $sharedcourse = array_shift($sharedcourses);
 
279
        // It should be course 1.
 
280
        $this->assertEquals($sharedcourse->id, $course1->id);
 
281
    }
253
282
}