/** * Setup. */ public function setUp() { // Calling parent is good, always. parent::setUp(); // We always need enabled WS for this testcase. set_config('enablewebservices', '1'); }
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; }
protected function setUp() { global $CFG; parent::setup(); $this->resetAfterTest(true); $CFG->grade_droplow = -1; $CFG->grade_keephigh = -1; $CFG->grade_aggregation = -1; $CFG->grade_aggregateonlygraded = -1; $CFG->grade_aggregateoutcomes = -1; $CFG->grade_aggregatesubcats = -1; $this->course = $this->getDataGenerator()->create_course(); $this->courseid = $this->course->id; $this->user[0] = $this->getDataGenerator()->create_user(); $this->user[1] = $this->getDataGenerator()->create_user(); $this->user[2] = $this->getDataGenerator()->create_user(); $this->user[3] = $this->getDataGenerator()->create_user(); $this->userid = $this->user[0]->id; $this->load_modules(); $this->load_scales(); $this->load_grade_categories(); $this->load_grade_items(); $this->load_grade_grades(); $this->load_grade_outcomes(); }
/** * 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); }
public function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(true); $CFG->defaultfrontpageroleid = null; }
/** * 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(); }
/** * Tear down 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 tearDown() { global $PAGE, $SESSION; $PAGE = null; \core\session\manager::init_empty_session(); $SESSION->notifications = []; parent::tearDown(); }
/** * 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(); }
protected function tearDown() { $this->teamwork = null; $this->course = null; $this->cm = null; $this->context = null; parent::tearDown(); }
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 tearDown() { $this->databasehelper = null; $this->course = null; $this->users = null; $this->resource = null; parent::tearDown(); }
/** * 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(); }
protected function setUp() { global $DB; parent::setUp(); $this->resetAfterTest(); $DB->delete_records('filter_active', array()); $DB->delete_records('filter_config', array()); }
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 }
/** * 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(); }
protected function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(true); $CFG->enableavailability = 1; $CFG->enablecompletion = 1; }
protected function tearDown() { $this->db = null; $this->previouscourseattributes = null; $this->previouscourses = null; $this->currentyear = null; $this->currentcourseattributes = null; $this->currentcourse = null; parent::tearDown(); }
/** * 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); }
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()); }
/** * Cleans things up after this test case has run. */ protected function tearDown() { global $SESSION; parent::tearDown(); if ($this->initiallang !== null) { $SESSION->lang = $this->initiallang; $this->initiallang = null; } else { unset($SESSION->lang); } }
protected function setUp() { parent::setUp(); $this->testfile = __DIR__ . '/fixtures/test.txt'; $fs = get_file_storage(); $context = context_system::instance(); if (!($file = $fs->get_file($context->id, 'phpunit', 'data', 0, '/', 'test.txt'))) { $file = $fs->create_file_from_pathname(array('contextid' => $context->id, 'component' => 'phpunit', 'filearea' => 'data', 'itemid' => 0, 'filepath' => '/', 'filename' => 'test.txt'), $this->testfile); } $this->files = array('test.test' => $this->testfile, 'testíček.txt' => $this->testfile, 'Prüfung.txt' => $this->testfile, '测试.txt' => $this->testfile, '試験.txt' => $this->testfile, 'Žluťoučký/Koníček.txt' => $file); }
function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(true); $CFG->backup_error_log_logger_level = backup::LOG_NONE; $CFG->backup_output_indented_logger_level = backup::LOG_NONE; $CFG->backup_file_logger_level = backup::LOG_NONE; $CFG->backup_database_logger_level = backup::LOG_NONE; unset($CFG->backup_file_logger_extra); $CFG->backup_file_logger_level_extra = backup::LOG_NONE; }
/** * The setup function is used to place the DB in its initial state. * */ protected function setUp() { // This needs to be here for the dummy test below. $this->resetAfterTest(true); // Create all of the test data. $this->create_course(); $this->create_grouping(); $this->create_groups(); $this->create_feedback(); $this->create_feedback_items(); $this->answer_feedback(); parent::setUp(); }
/** * Initalize test wide variable, it is called in start of the testcase */ protected function setUp() { global $CFG; parent::setUp(); $this->resetAfterTest(); $this->setAdminUser(); $this->setTimezone('Australia/Perth'); // Get form data. $form = new temp_form_datetime(); $this->mform = $form->getform(); // Set test values. $this->testvals = array(array('minute' => 0, 'hour' => 0, 'day' => 1, 'month' => 7, 'year' => 2011, 'usertimezone' => 'America/Moncton', 'timezone' => 'America/Moncton', 'timestamp' => 1309489200), array('minute' => 0, 'hour' => 0, 'day' => 1, 'month' => 7, 'year' => 2011, 'usertimezone' => 'America/Moncton', 'timezone' => 99, 'timestamp' => 1309489200), array('minute' => 0, 'hour' => 23, 'day' => 30, 'month' => 6, 'year' => 2011, 'usertimezone' => 'America/Moncton', 'timezone' => -4, 'timestamp' => 1309489200), array('minute' => 0, 'hour' => 23, 'day' => 30, 'month' => 6, 'year' => 2011, 'usertimezone' => -4, 'timezone' => 99, 'timestamp' => 1309489200), array('minute' => 0, 'hour' => 0, 'day' => 1, 'month' => 7, 'year' => 2011, 'usertimezone' => 0.0, 'timezone' => 0.0, 'timestamp' => 1309478400), array('minute' => 0, 'hour' => 0, 'day' => 1, 'month' => 7, 'year' => 2011, 'usertimezone' => 0.0, 'timezone' => 99, 'timestamp' => 1309478400)); }
/** * Asserts that two variables are equal. * * @param mixed $expected * @param mixed $actual * @param string $message * @param float $delta * @param integer $maxDepth * @param boolean $canonicalize * @param boolean $ignoreCase */ public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { // Nasty cheating hack: prevent random failures on timemodified field. if (is_object($expected) and is_object($actual)) { if (property_exists($expected, 'timemodified') and property_exists($actual, 'timemodified')) { if ($expected->timemodified + 1 == $actual->timemodified) { $expected = clone $expected; $expected->timemodified = $actual->timemodified; } } } parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); }