/** * Setup. */ public function setUp() { // Calling parent is good, always. parent::setUp(); // We always need enabled WS for this testcase. set_config('enablewebservices', '1'); }
/** * Setup function * - Allow changes to CFG->debug for testing purposes. */ protected function setUp() { global $CFG, $DB; parent::setUp(); // Settings to force statistic to run during testing. $this->setTimezone(self::TIMEZONE); core_date::set_default_server_timezone(); $CFG->statsfirstrun = 'all'; $CFG->statslastdaily = 0; // Figure out the broken day start so I can figure out when to the start time should be. $time = time(); // This nonsense needs to be rewritten. $date = new DateTime('now', core_date::get_server_timezone_object()); $offset = $date->getOffset(); $stime = $time + $offset; $stime = intval($stime / (60 * 60 * 24)) * 60 * 60 * 24; $stime -= $offset; $shour = intval(($time - $stime) / (60 * 60)); if ($DB->record_exists('user', array('username' => 'user1'))) { return; } // Set up the database. $datagen = self::getDataGenerator(); $user1 = $datagen->create_user(array('username' => 'user1')); $user2 = $datagen->create_user(array('username' => 'user2')); $course1 = $datagen->create_course(array('shortname' => 'course1')); $datagen->enrol_user($user1->id, $course1->id); $this->generate_replacement_list(); // Reset between tests. $this->resetAfterTest(); }
public function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(true); $CFG->defaultfrontpageroleid = null; }
protected function setUp() { parent::setUp(); $this->testpage = new moodle_page(); $this->testpage->set_context(context_system::instance()); $this->blockmanager = new testable_block_manager($this->testpage); }
public function setUp() { parent::setUp(); stack_utils::clear_config_cache(); self::setup_test_maxima_connection($this); $this->resetAfterTest(); }
/** * Setup the tests. */ protected function setUp() { global $DB; parent::setUp(); $this->resetAfterTest(); // Create default course. $course = $this->getDataGenerator()->create_course(array('category' => 1, 'shortname' => 'ANON')); $this->assertNotEmpty($course); $page = $this->getDataGenerator()->create_module('page', array('course' => $course->id)); $this->assertNotEmpty($page); // Create default group. $group = new stdClass(); $group->courseid = $course->id; $group->name = 'ANON'; $group->id = $DB->insert_record('groups', $group); // Create default user. $user = $this->getDataGenerator()->create_user(array('username' => 'testuser', 'firstname' => 'Jimmy', 'lastname' => 'Kinnon')); // Create default tag. $tag = $this->getDataGenerator()->create_tag(array('userid' => $user->id, 'rawname' => 'Testtagname', 'isstandard' => 1)); // Create default post. $post = new stdClass(); $post->userid = $user->id; $post->groupid = $group->id; $post->content = 'test post content text'; $post->module = 'blog'; $post->id = $DB->insert_record('post', $post); // Grab important ids. $this->courseid = $course->id; $this->cmid = $page->cmid; $this->groupid = $group->id; $this->userid = $user->id; $this->tagid = $tag->id; $this->postid = $post->id; }
/** * Setup testing environment */ protected function setUp() { parent::setUp(); $cm = new stdclass(); $course = new stdclass(); $context = new stdclass(); $workshop = (object) array('id' => 42, 'strategy' => 'rubric'); $this->workshop = new workshop($workshop, $cm, $course, $context); $this->strategy = new testable_workshop_rubric_strategy($this->workshop); // prepare dimensions definition $dim = new stdclass(); $dim->id = 6; $dim->levels[10] = (object) array('id' => 10, 'grade' => 0); $dim->levels[13] = (object) array('id' => 13, 'grade' => 2); $dim->levels[14] = (object) array('id' => 14, 'grade' => 6); $dim->levels[16] = (object) array('id' => 16, 'grade' => 8); $this->strategy->dimensions[$dim->id] = $dim; $dim = new stdclass(); $dim->id = 8; $dim->levels[17] = (object) array('id' => 17, 'grade' => 0); $dim->levels[18] = (object) array('id' => 18, 'grade' => 1); $dim->levels[19] = (object) array('id' => 19, 'grade' => 2); $dim->levels[20] = (object) array('id' => 20, 'grade' => 3); $this->strategy->dimensions[$dim->id] = $dim; $dim = new stdclass(); $dim->id = 10; $dim->levels[27] = (object) array('id' => 27, 'grade' => 10); $dim->levels[28] = (object) array('id' => 28, 'grade' => 20); $dim->levels[29] = (object) array('id' => 29, 'grade' => 30); $dim->levels[30] = (object) array('id' => 30, 'grade' => 40); $this->strategy->dimensions[$dim->id] = $dim; }
/** * Setup function * - Allow changes to CFG->debug for testing purposes. */ protected function setUp() { global $CFG, $DB; parent::setUp(); // Settings to force statistic to run during testing. $CFG->timezone = self::TIMEZONE; $CFG->statsfirstrun = 'all'; $CFG->statslastdaily = 0; $CFG->statslastexecution = 0; // Figure out the broken day start so I can figure out when to the start time should be. $time = time(); $offset = get_timezone_offset($CFG->timezone); $stime = $time + $offset; $stime = intval($stime / (60 * 60 * 24)) * 60 * 60 * 24; $stime -= $offset; $shour = intval(($time - $stime) / (60 * 60)); $CFG->statsruntimestarthour = $shour; $CFG->statsruntimestartminute = 0; if ($DB->record_exists('user', array('username' => 'user1'))) { return; } // Set up the database. $datagen = self::getDataGenerator(); $user1 = $datagen->create_user(array('username' => 'user1')); $user2 = $datagen->create_user(array('username' => 'user2')); $course1 = $datagen->create_course(array('shortname' => 'course1')); $datagen->enrol_user($user1->id, $course1->id); $this->generate_replacement_list(); // Reset between tests. $this->resetAfterTest(); }
/** * Pre-test setup. Preserves $CFG. */ public function setUp() { global $CFG; parent::setUp(); // Reset $CFG and $SERVER. $this->resetAfterTest(true); // Consistent initial setup: all players disabled. $CFG->core_media_enable_html5video = false; $CFG->core_media_enable_html5audio = false; $CFG->core_media_enable_mp3 = false; $CFG->core_media_enable_flv = false; $CFG->core_media_enable_wmp = false; $CFG->core_media_enable_qt = false; $CFG->core_media_enable_rm = false; $CFG->core_media_enable_youtube = false; $CFG->core_media_enable_vimeo = false; $CFG->core_media_enable_swf = false; // Strict headers turned off. $CFG->xmlstrictheaders = false; $_SERVER = array('HTTP_USER_AGENT' => ''); $this->pretend_to_be_safari(); }
protected function setUp() { parent::setUp(); $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->setUser($user); }
/** * Setup testing environment */ protected function setUp() { parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); $workshop = $this->getDataGenerator()->create_module('workshop', array('strategy' => 'rubric', 'course' => $course)); $cm = get_fast_modinfo($course)->instances['workshop'][$workshop->id]; $this->workshop = new workshop($workshop, $cm, $course); $this->strategy = new testable_workshop_rubric_strategy($this->workshop); // prepare dimensions definition $dim = new stdclass(); $dim->id = 6; $dim->levels[10] = (object) array('id' => 10, 'grade' => 0); $dim->levels[13] = (object) array('id' => 13, 'grade' => 2); $dim->levels[14] = (object) array('id' => 14, 'grade' => 6); $dim->levels[16] = (object) array('id' => 16, 'grade' => 8); $this->strategy->dimensions[$dim->id] = $dim; $dim = new stdclass(); $dim->id = 8; $dim->levels[17] = (object) array('id' => 17, 'grade' => 0); $dim->levels[18] = (object) array('id' => 18, 'grade' => 1); $dim->levels[19] = (object) array('id' => 19, 'grade' => 2); $dim->levels[20] = (object) array('id' => 20, 'grade' => 3); $this->strategy->dimensions[$dim->id] = $dim; $dim = new stdclass(); $dim->id = 10; $dim->levels[27] = (object) array('id' => 27, 'grade' => 10); $dim->levels[28] = (object) array('id' => 28, 'grade' => 20); $dim->levels[29] = (object) array('id' => 29, 'grade' => 30); $dim->levels[30] = (object) array('id' => 30, 'grade' => 40); $this->strategy->dimensions[$dim->id] = $dim; }
/** * Set up the test environment. */ protected function setUp() { parent::setUp(); $this->setAdminUser(); $this->matrix = new decimal_matrix(); $this->associator = new cosine_similarity_associator($this->matrix); }
protected function setUp() { parent::setUp(); $this->recommendator = new concrete_recommendator(new cosine_similarity_associator(new decimal_matrix())); $this->currentyear = 2016; $this->courseattributes = array('fullname' => 'Software Engineering II', 'startdate' => strtotime("16-02-{$this->currentyear}")); $this->courses = $this->create_courses($this->courseattributes, 1); }
public function setUp() { parent::setUp(); $this->resetAfterTest(true); if (!($this->tempdir = make_temp_directory('assignfeedback_pdf'))) { throw new coding_exception("Unable to create temporary directory"); } }
protected function setUp() { global $CFG; parent::setUp(); // Discard error logs. $this->oldlog = ini_get('error_log'); ini_set('error_log', "{$CFG->dataroot}/testlog.log"); }
/** * Setup required for all notification tests. * * This includes emptying the list of notifications on the session, resetting any session which exists, and setting * up a new moodle_page object. */ public function setUp() { global $PAGE, $SESSION; parent::setUp(); $PAGE = new moodle_page(); \core\session\manager::init_empty_session(); $SESSION->notifications = []; }
protected function setUp() { global $DB; parent::setUp(); $this->resetAfterTest(); $DB->delete_records('filter_active', array()); $DB->delete_records('filter_config', array()); }
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ public function setUp() { $class = $this->get_class_name(); if (!class_exists($class) || !$class::are_requirements_met()) { $this->markTestSkipped('Could not test ' . $class . '. Requirements are not met.'); } parent::setUp(); }
/** * Create temporary entries in the database for these tests. * These tests have to work no matter the data currently in the database * (meaning they should run on a brand new site). This means several items of * data have to be artificially inseminated (:-) in the DB. */ protected function setUp() { parent::setUp(); // Set global category settings to -1 (not force). eventslib_sample_function_handler('reset'); eventslib_sample_handler_class::static_method('reset'); $this->resetAfterTest(); }
/** * Sets up the fixture * This method is called before a test is executed. */ public function setUp() { parent::setUp(); $this->resetAfterTest(true); $this->course1 = $this->getDataGenerator()->create_course(); $this->course2 = $this->getDataGenerator()->create_course(); $this->feedback = $this->getDataGenerator()->create_module('feedback', array('course' => SITEID)); $this->user = $this->getDataGenerator()->create_user(); }
/** setup testing environment */ protected function setUp() { parent::setUp(); $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); $teamwork = $this->getDataGenerator()->create_module('teamwork', array('course' => $course)); $cm = get_coursemodule_from_instance('teamwork', $teamwork->id, $course->id, false, MUST_EXIST); $this->teamwork = new testable_teamwork($teamwork, $cm, $course); }
/** setup testing environment */ protected function setUp() { parent::setUp(); $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); $workshop = $this->getDataGenerator()->create_module('workshop', array('course' => $course)); $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); $this->workshop = new testable_workshop($workshop, $cm, $course); }
protected function setUp() { parent::setUp(); $this->resetAfterTest(true); $this->contextid = 666; // Let's assume this is the context for the forum $this->fill_records(); // Add common stuff needed by various test methods }
protected function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(true); $CFG->enableavailability = 1; $CFG->enablecompletion = 1; }
/** * Set up the testing environment. */ protected function setUp() { parent::setUp(); $this->setAdminUser(); // Create a teamwork activity. $this->course = $this->getDataGenerator()->create_course(); $this->teamwork = $this->getDataGenerator()->create_module('teamwork', array('course' => $this->course)); $this->cm = get_coursemodule_from_instance('teamwork', $this->teamwork->id); $this->context = context_module::instance($this->cm->id); }
/** * Setup testing environment */ protected function setUp() { parent::setUp(); $cm = new stdclass(); $course = new stdclass(); $context = new stdclass(); $workshop = (object) array('id' => 42, 'strategy' => 'numerrors'); $this->workshop = new workshop($workshop, $cm, $course, $context); $this->strategy = new testable_workshop_numerrors_strategy($this->workshop); }
protected function setUp() { global $CFG; parent::setUp(); require $CFG->dirroot . '/question/type/coderunner/tests/config.php'; $this->resetAfterTest(); $this->setAdminUser(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); $this->category = $generator->create_question_category(array()); }
/** * Sets up the test class */ protected function setUp() { global $CFG; parent::setUp(); // We need to disable these if they are enabled to that we can predict // the output. $CFG->cssoptimiserstats = false; $CFG->cssoptimiserpretty = false; $this->resetAfterTest(true); }
/** * Pre-test setup. Preserves $CFG. */ public function setUp() { parent::setUp(); // Reset $CFG and $SERVER. $this->resetAfterTest(); // Consistent initial setup: all players disabled. \core\plugininfo\media::set_enabled_plugins('videojs'); // Pretend to be using Firefox browser (must support ogg for tests to work). core_useragent::instance(true, 'Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0 '); }
protected function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(); $CFG->enableavailability = 1; $CFG->enablecompletion = 1; $user = $this->getDataGenerator()->create_user(); $this->setUser($user); }