MDL-52471 tests: simplify setup code

Test code was not using the generator for simple enrollments, couldn't
help to fix when noticed.
This commit is contained in:
Dan Poltawski
2015-12-10 18:00:41 +00:00
parent a3f65f8b5b
commit 8640c059d8
+1 -9
View File
@@ -59,15 +59,7 @@ class core_completionlib_testcase extends advanced_testcase {
// Create a course with activities.
$this->course = $this->getDataGenerator()->create_course(array('enablecompletion' => true));
$this->user = $this->getDataGenerator()->create_user();
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
$this->assertNotEmpty($studentrole);
// Get manual enrolment plugin and enrol user.
require_once($CFG->dirroot.'/enrol/manual/locallib.php');
$manplugin = enrol_get_plugin('manual');
$maninstance = $DB->get_record('enrol', array('courseid' => $this->course->id, 'enrol' => 'manual'), '*', MUST_EXIST);
$manplugin->enrol_user($maninstance, $this->user->id, $studentrole->id);
$this->assertEquals(1, $DB->count_records('user_enrolments'));
$this->getDataGenerator()->enrol_user($this->user->id, $this->course->id);
$this->module1 = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id));
$this->module2 = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id));