Пример #1
0
 /**
  * Run defaultcourses cron.
  */
 public function execute()
 {
     dc_enrol_default_courses();
 }
Пример #2
0
 /**
  * Create new users, enrol them in default courses, assert that each default
  * course has the new users.
  */
 public function test_enrol_default_courses()
 {
     // Make the dummy course a default course.
     set_config('courseids', $this->dummycourse->id, 'local_defaultcourses');
     // Try to enrol users (none) in the default course.
     dc_enrol_default_courses();
     // How many enrolments are there?
     $initialenrolcount = count_enrolled_users($this->dummycoursecontext);
     // Expected: no enrolments.
     $this->assertEquals(0, $initialenrolcount);
     // Create three dummy users.
     $this->user = $this->getDataGenerator()->create_user(array('email' => 'test@example.com', 'username' => 'dctestuser'));
     $this->user2 = $this->getDataGenerator()->create_user(array('email' => 'test@example.com', 'username' => 'dctestuser2'));
     $this->user3 = $this->getDataGenerator()->create_user(array('email' => 'test@example.com', 'username' => 'dctestuser3'));
     // Try again to enrol users (three) in the default course.
     dc_enrol_default_courses();
     // How many enrolments are there now?
     $subsequentenrolcount = count_enrolled_users($this->dummycoursecontext);
     // Expected: three enrolments.
     $this->assertEquals(3, $subsequentenrolcount);
 }