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 14:50:54 +00:00
parent 194a02e409
commit ef5df7b721

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));