/** * Test enrol function */ public function test_enrol() { global $DB; // Fixture. $elisgen = new elis_program_datagenerator($DB); $pgm = $elisgen->create_program(); $track = $elisgen->create_track(array('curid' => $pgm->id)); $course = $elisgen->create_course(); $pmclass = $elisgen->create_pmclass(array('courseid' => $course->id)); $user = $elisgen->create_user(); $elisgen->assign_class_to_track($pmclass->id, $course->id, $track->id, true); $result = usertrack::enrol($user->id, $track->id); $this->assertTrue($result); // Validate curriculumstudent rec. $rec = $DB->get_record(curriculumstudent::TABLE, array('curriculumid' => $pgm->id, 'userid' => $user->id)); $this->assertNotEmpty($rec); // Validate student rec. $rec = $DB->get_record(student::TABLE, array('classid' => $pmclass->id, 'userid' => $user->id)); $this->assertNotEmpty($rec); }
/** * Test failure conditions. * @dataProvider dataprovider_failure * @expectedException moodle_exception * @param array $tracktoupdate The incoming track data. */ public function test_failure(array $tracktoupdate) { global $DB; $this->give_permissions(array('local/elisprogram:track_edit')); // Setup program and track. $datagen = new elis_program_datagenerator($DB); $program = $datagen->create_program(array('idnumber' => 'test_program_idnumber', 'name' => 'ProgramName')); $track = $datagen->create_track(array('idnumber' => 'testtrack', 'name' => 'testtrackname', 'curid' => $program->id)); $response = local_datahub_elis_track_update::track_update($tracktoupdate); }
/** * Test failure conditions. * @dataProvider dataprovider_failure * @expectedException moodle_exception * @param array $data The incoming track enrolment data. */ public function test_failure(array $data) { global $DB; // Create test program and track. $datagen = new elis_program_datagenerator($DB); $program = $datagen->create_program(array('idnumber' => 'TestProgramForTrack')); $track = $datagen->create_track(array('idnumber' => 'TestTrackForProgram', 'curid' => $program->id)); $this->give_permissions(array('local/elisprogram:track_enrol')); $response = local_datahub_elis_track_enrolment_delete::track_enrolment_delete($data); }