public function test_get_results()
 {
     global $DB;
     $field = new mr_fixture_user_profile(mr_fixture_manager::instance()->get('cat'), array('shortname' => 'simpletest'));
     $this->assertEqual($field->get_results(), new stdClass());
     $field->build();
     $record = $DB->get_record('user_info_field', array('shortname' => 'simpletest'), '*', MUST_EXIST);
     $this->assertEqual($field->get_results(), $record);
     $field->destroy();
     $this->assertEqual($field->get_results(), new stdClass());
 }
Пример #2
0
 public function test_get_results()
 {
     global $DB;
     $fm = mr_fixture_manager::instance();
     $params = array('name' => 'simpletest', 'courseid' => $fm->get('course')->get('id'));
     $group = new mr_fixture_group($fm->get('course'), $params);
     $this->assertEqual($group->get_results(), new stdClass());
     $group->build();
     $record = $DB->get_record('groups', $params, '*', MUST_EXIST);
     $this->assertEqual($group->get_results(), $record);
     $group->destroy();
     $this->assertEqual($group->get_results(), new stdClass());
 }
 public function test_get_results()
 {
     global $DB;
     $fm = mr_fixture_manager::instance();
     $userid = $fm->get('user')->get('id');
     $groupid = $fm->get('group')->get('id');
     $gm = new mr_fixture_group_member($fm->get('group'), $fm->get('enroll'));
     $this->assertEqual($gm->get_results(), new stdClass());
     $gm->build();
     $record = $DB->get_record('groups_members', array('groupid' => $groupid, 'userid' => $userid), '*', MUST_EXIST);
     $this->assertEqual($gm->get_results(), $record);
     $gm->destroy();
     $this->assertEqual($gm->get_results(), new stdClass());
 }
 public function test_get_results()
 {
     global $DB;
     $fm = mr_fixture_manager::instance();
     $userid = $fm->get('user')->get('id');
     $roleid = $fm->get('role')->get('id');
     $contextid = context_course::instance($fm->get('course')->get('id'))->id;
     $ra = new mr_fixture_role_assignment($fm->get('role'), $fm->get('user'), $fm->get('course'));
     $this->assertEqual($ra->get_results(), new stdClass());
     $ra->build();
     $record = $DB->get_record('role_assignments', array('roleid' => $roleid, 'contextid' => $contextid, 'userid' => $userid), '*', MUST_EXIST);
     $this->assertEqual($ra->get_results(), $record);
     $ra->destroy();
     $this->assertEqual($ra->get_results(), new stdClass());
 }
 public function test_create_instance()
 {
     global $DB;
     $fm = mr_fixture_manager::instance();
     $context = context_course::instance($fm->get('course')->get('id'));
     $enroll = enrol_get_plugin('manual');
     if ($instance = $DB->get_record('enrol', array('enrol' => 'manual', 'courseid' => $fm->get('course')->get('id')))) {
         $enroll->delete_instance($instance);
     }
     $this->assertFalse(is_enrolled($context, $fm->get('user')->get_results()));
     $enrollment = new mr_fixture_enrollment($fm->get('course'), $fm->get('user'), $enroll);
     $enrollment->build();
     $this->assertTrue(is_enrolled($context, $fm->get('user')->get_results()));
 }
Пример #6
0
 /**
  * Convenience method for unit tests, call in your tearDown
  * method to delete all of the fixtures from all fixture managers
  * you may have created.
  *
  * @static
  */
 public static function tearDown()
 {
     // Don't worry about cleanup, Moodle will reset the database anyways.
     self::$instances = array();
     self::$instance = null;
 }
 public function test_tearDown()
 {
     $course = new mr_fixture_course(array('shortname' => 'simpletest', 'idnumber' => 'simpletest'));
     $manager = new mr_fixture_manager();
     $manager->set('course', $course);
     $course2 = new mr_fixture_course(array('shortname' => 'simpletest2', 'idnumber' => 'simpletest2'));
     $manager2 = new mr_fixture_manager();
     $manager2->set('course', $course2);
     $course3 = new mr_fixture_course(array('shortname' => 'simpletest3', 'idnumber' => 'simpletest3'));
     mr_fixture_manager::instance()->set('course', $course3);
     mr_fixture_manager::tearDown();
     $this->assertFalse($course->exists());
     $this->assertFalse($course2->exists());
     $this->assertFalse($course3->exists());
 }