当前位置: 首页>>代码示例>>PHP>>正文


PHP advanced_testcase::setUp方法代码示例

本文整理汇总了PHP中advanced_testcase::setUp方法的典型用法代码示例。如果您正苦于以下问题:PHP advanced_testcase::setUp方法的具体用法?PHP advanced_testcase::setUp怎么用?PHP advanced_testcase::setUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在advanced_testcase的用法示例。


在下文中一共展示了advanced_testcase::setUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Setup.
  */
 public function setUp()
 {
     // Calling parent is good, always.
     parent::setUp();
     // We always need enabled WS for this testcase.
     set_config('enablewebservices', '1');
 }
开发者ID:rushi963,项目名称:moodle,代码行数:10,代码来源:lib_test.php

示例2: setUp

 /**
  * 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();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:statslib_test.php

示例3: setUp

 public function setUp()
 {
     global $CFG;
     parent::setUp();
     $this->resetAfterTest(true);
     $CFG->defaultfrontpageroleid = null;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:7,代码来源:rating_test.php

示例4: setUp

 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);
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:7,代码来源:blocklib_test.php

示例5: setUp

 public function setUp()
 {
     parent::setUp();
     stack_utils::clear_config_cache();
     self::setup_test_maxima_connection($this);
     $this->resetAfterTest();
 }
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:7,代码来源:test_base.php

示例6: setUp

 /**
  * 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;
 }
开发者ID:janeklb,项目名称:moodle,代码行数:37,代码来源:events_test.php

示例7: setUp

 /**
  * 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;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:35,代码来源:lib_test.php

示例8: setUp

 /**
  * 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();
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:35,代码来源:statslib_test.php

示例9: setUp

    /**
     * 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();
    }
开发者ID:nicusX,项目名称:moodle,代码行数:28,代码来源:medialib_test.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->resetAfterTest();
     $user = $this->getDataGenerator()->create_user();
     $this->setUser($user);
 }
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:7,代码来源:coursecatlib_test.php

示例11: setUp

 /**
  * 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;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:36,代码来源:lib_test.php

示例12: setUp

 /**
  * 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);
 }
开发者ID:julenpardo,项目名称:moodle-block_mycourse_recommendations,代码行数:10,代码来源:cosine_similarity_associator_test.php

示例13: setUp

 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);
 }
开发者ID:julenpardo,项目名称:moodle-block_mycourse_recommendations,代码行数:8,代码来源:abstract_recommendator_test.php

示例14: setUp

 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");
     }
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:8,代码来源:mypdflib_test.php

示例15: setUp

 protected function setUp()
 {
     global $CFG;
     parent::setUp();
     // Discard error logs.
     $this->oldlog = ini_get('error_log');
     ini_set('error_log', "{$CFG->dataroot}/testlog.log");
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:8,代码来源:ajaxlib_test.php


注:本文中的advanced_testcase::setUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。