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


PHP phpunit_util::reset_debugging方法代码示例

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


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

示例1: test_get_year_for_tables

 /**
  * Tests the get_year_for_tables function.
  */
 public function test_get_year_for_tables()
 {
     $this->resetAfterTest();
     // Create a couple of courses for testing.
     $course1 = $this->getDataGenerator()->create_course(array('startdate' => strtotime('2013-01-04 10:00')));
     $course2 = $this->getDataGenerator()->create_course(array('startdate' => strtotime('2020-01-04 10:00')));
     $course3 = $this->getDataGenerator()->create_course(array('startdate' => strtotime('2021-01-04 10:00')));
     // System not turned on.
     $this->assertFalse(year_tables::get_year_for_tables());
     // System turned on, initially transferring. Test with course and no course.
     set_config(year_tables::CONFIG_ENABLED, year_tables::ENABLED_TRANSFERRING, 'local_ousearch');
     $this->assertFalse(year_tables::get_year_for_tables());
     $this->assertFalse(year_tables::get_year_for_tables($course1));
     // If any course is transferring, the non-course ones will return default.
     set_config(year_tables::CONFIG_TRANSFERRING_COURSE, $course1->id, 'local_ousearch');
     $this->assertEquals(year_tables::NON_COURSE_YEAR, year_tables::get_year_for_tables());
     $this->assertFalse(year_tables::get_year_for_tables($course1));
     // Once course 1 is finished, course 2 will still return false and course 1
     // should return its year.
     set_config(year_tables::CONFIG_TRANSFERRING_COURSE, $course2->id, 'local_ousearch');
     $this->assertEquals(2013, year_tables::get_year_for_tables($course1));
     $this->assertFalse(year_tables::get_year_for_tables($course2));
     // Now we'll set it to mark that everything was transferred.
     set_config(year_tables::CONFIG_ENABLED, year_tables::ENABLED_ON, 'local_ousearch');
     unset_config(year_tables::CONFIG_TRANSFERRING_COURSE, 'local_ousearch');
     // 2020 should show a warning that we're running out of tables.
     $this->assertEquals(2020, year_tables::get_year_for_tables($course2));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // 2021 should throw exception.
     try {
         year_tables::get_year_for_tables($course3);
         $this->fail();
     } catch (moodle_exception $e) {
         $this->assertContains('start date beyond that supported by the OU search system', $e->getMessage());
     }
 }
开发者ID:profcab,项目名称:moodle-local_ousearch,代码行数:40,代码来源:year_tables_test.php

示例2: test_info_section

 /**
  * Tests the info_section class (is_available, get_full_information).
  */
 public function test_info_section()
 {
     global $DB;
     // Create a course.
     $this->setAdminUser();
     $this->resetAfterTest();
     $generator = $this->getDataGenerator();
     $course = $generator->create_course(array('numsections' => 4), array('createsections' => true));
     // Set up the availability option for the sections to mock options.
     $DB->set_field('course_sections', 'availability', '{"op":"|","show":true,"c":[' . '{"type":"mock","a":false,"m":"public"}]}', array('course' => $course->id, 'section' => 1));
     $DB->set_field('course_sections', 'availability', '{"op":"|","show":true,"c":[' . '{"type":"mock","a":true,"m":"enemy"}]}', array('course' => $course->id, 'section' => 2));
     // Third section is invalid. (Fourth has no availability setting.)
     $DB->set_field('course_sections', 'availability', '{{{', array('course' => $course->id, 'section' => 3));
     $modinfo = get_fast_modinfo($course);
     $sections = $modinfo->get_section_info_all();
     // Do availability and full information checks.
     $info = new info_section($sections[1]);
     $information = '';
     $this->assertFalse($info->is_available($information));
     $this->assertEquals('SA: public', $information);
     $this->assertEquals('SA: [FULL]public', $info->get_full_information());
     $info = new info_section($sections[2]);
     $this->assertTrue($info->is_available($information));
     $this->assertEquals('', $information);
     $this->assertEquals('SA: [FULL]enemy', $info->get_full_information());
     // Check invalid one.
     $info = new info_section($sections[3]);
     $this->assertFalse($info->is_available($information));
     $debugging = phpunit_util::get_debugging_messages();
     phpunit_util::reset_debugging();
     $this->assertEquals(1, count($debugging));
     $this->assertContains('Invalid availability', $debugging[0]->message);
     // Check empty one.
     $info = new info_section($sections[4]);
     $this->assertTrue($info->is_available($information));
     $this->assertEquals('', $information);
     $this->assertEquals('', $info->get_full_information());
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:41,代码来源:info_test.php

示例3: test_is_user_access_restricted_by_conditional_access

 /**
  * Test is_user_access_restricted_by_conditional_access()
  *
  * The underlying conditional access system is more thoroughly tested in lib/tests/conditionlib_test.php
  */
 public function test_is_user_access_restricted_by_conditional_access()
 {
     global $DB, $CFG;
     $this->resetAfterTest();
     // Enable conditional availability before creating modules, otherwise the condition data is not written in DB.
     $CFG->enableavailability = true;
     // Create a course.
     $course = $this->getDataGenerator()->create_course();
     // 1. Create an activity that is currently unavailable and hidden entirely (for students).
     $assign1 = $this->getDataGenerator()->create_module('assign', array('course' => $course->id), array('availability' => '{"op":"|","show":false,"c":[' . '{"type":"date","d":">=","t":' . (time() + 10000) . '}]}'));
     // 2. Create an activity that is currently available.
     $assign2 = $this->getDataGenerator()->create_module('assign', array('course' => $course->id));
     // 3. Create an activity that is currently unavailable and set to be greyed out.
     $assign3 = $this->getDataGenerator()->create_module('assign', array('course' => $course->id), array('availability' => '{"op":"|","show":true,"c":[' . '{"type":"date","d":">=","t":' . (time() + 10000) . '}]}'));
     // Set up a teacher.
     $coursecontext = context_course::instance($course->id);
     $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'), '*', MUST_EXIST);
     $teacher = $this->getDataGenerator()->create_user();
     role_assign($teacherrole->id, $teacher->id, $coursecontext);
     // If conditional availability is disabled the activity will always be unrestricted.
     $CFG->enableavailability = false;
     $cm = get_fast_modinfo($course)->instances['assign'][$assign1->id];
     $this->assertTrue($cm->uservisible);
     // Test deprecated function.
     $this->assertFalse($cm->is_user_access_restricted_by_conditional_access());
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // Turn on conditional availability and reset the get_fast_modinfo cache.
     $CFG->enableavailability = true;
     get_fast_modinfo($course, 0, true);
     // The unavailable, hidden entirely activity should now be restricted.
     $cm = get_fast_modinfo($course)->instances['assign'][$assign1->id];
     $this->assertFalse($cm->uservisible);
     $this->assertFalse($cm->available);
     $this->assertEquals('', $cm->availableinfo);
     // Test deprecated function.
     $this->assertTrue($cm->is_user_access_restricted_by_conditional_access());
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // If the activity is available it should not be restricted.
     $cm = get_fast_modinfo($course)->instances['assign'][$assign2->id];
     $this->assertTrue($cm->uservisible);
     $this->assertTrue($cm->available);
     // If the activity is unavailable and set to be greyed out it should not be restricted.
     $cm = get_fast_modinfo($course)->instances['assign'][$assign3->id];
     $this->assertFalse($cm->uservisible);
     $this->assertFalse($cm->available);
     $this->assertNotEquals('', (string) $cm->availableinfo);
     // Test deprecated function (weird case, it actually checks visibility).
     $this->assertFalse($cm->is_user_access_restricted_by_conditional_access());
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // If the activity is unavailable and set to be hidden entirely its restricted unless user has 'moodle/course:viewhiddenactivities'.
     // Switch to a teacher and reload the context info.
     $this->setUser($teacher);
     $this->assertTrue(has_capability('moodle/course:viewhiddenactivities', $coursecontext));
     $cm = get_fast_modinfo($course)->instances['assign'][$assign1->id];
     $this->assertTrue($cm->uservisible);
     $this->assertFalse($cm->available);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:65,代码来源:modinfolib_test.php

示例4: resetDebugging

 /**
  * Clear all previous debugging messages in current test.
  */
 public function resetDebugging()
 {
     phpunit_util::reset_debugging();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:7,代码来源:database_driver_testcase.php

示例5: assertDebuggingCalled

    /**
     * Assert that exactly debugging was just called once.
     *
     * Discards the debugging message if successful.
     *
     * @param null|string $debugmessage null means any
     * @param null|string $debuglevel null means any
     * @param string $message
     */
    public function assertDebuggingCalled($debugmessage = null, $debuglevel = null, $message = '') {
        $debugging = phpunit_util::get_debugging_messages();
        $count = count($debugging);

        if ($count == 0) {
            if ($message === '') {
                $message = 'Expectation failed, debugging() not triggered.';
            }
            $this->fail($message);
        }
        if ($count > 1) {
            if ($message === '') {
                $message = 'Expectation failed, debugging() triggered '.$count.' times.';
            }
            $this->fail($message);
        }
        $this->assertEquals(1, $count);

        $debug = reset($debugging);
        if ($debugmessage !== null) {
            $this->assertSame($debugmessage, $debug->message, $message);
        }
        if ($debuglevel !== null) {
            $this->assertSame($debuglevel, $debug->level, $message);
        }

        phpunit_util::reset_debugging();
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:37,代码来源:advanced_testcase.php

示例6: test_twf_is_subscribed_numeric

 /**
  * Test that the deprecated twf_is_subscribed accepts numeric twf IDs.
  */
 public function test_twf_is_subscribed_numeric()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create a course, with a twf.
     $course = $this->getDataGenerator()->create_course();
     $options = array('course' => $course->id, 'forcesubscribe' => FORUM_CHOOSESUBSCRIBE);
     $twf = $this->getDataGenerator()->create_module('twf', $options);
     // Create a user enrolled in the course as a students.
     list($author) = $this->helper_create_users($course, 1);
     // Check that the user is currently unsubscribed to the twf.
     $this->assertFalse(twf_is_subscribed($author->id, $twf->id));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // It should match the result of when it's called with the twf object.
     $this->assertFalse(twf_is_subscribed($author->id, $twf));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // And when the user is subscribed, we should also get the correct result.
     \mod_twf\subscriptions::subscribe_user($author->id, $twf);
     $this->assertTrue(twf_is_subscribed($author->id, $twf->id));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     // It should match the result of when it's called with the twf object.
     $this->assertTrue(twf_is_subscribed($author->id, $twf));
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:31,代码来源:subscriptions_test.php

示例7: test_ousearch_query

 public function test_ousearch_query()
 {
     global $DB;
     $this->resetAfterTest();
     // Create a bunch of search documents within test_zombie plugin.
     self::$zombiedocuments = array(1 => (object) array('title' => 'Document title', 'content' => 'First zombie document'), 2 => (object) array('title' => 'Another title', 'content' => 'Title title first'), 3 => (object) array('title' => 'Document title', 'content' => 'Not a zombie document title'), 4 => (object) array('title' => 'Delete me', 'content' => 'Delete me'), 100 => (object) array('title' => 'Bottle quantity', 'content' => 'There are this many bottles on the wall: 0'));
     for ($i = 101; $i <= 199; $i++) {
         self::$zombiedocuments[$i] = self::$zombiedocuments[100];
         self::$zombiedocuments[$i]->content = str_replace(': 0', ': ' . ($i - 100), self::$zombiedocuments[$i]->content);
     }
     foreach (self::$zombiedocuments as $key => $content) {
         $doc = new local_ousearch_document();
         $doc->init_test('zombie');
         $doc->set_int_refs($key);
         $doc->update($content->title, $content->content, null, null, null);
     }
     // Search for single unique term.
     $result = $this->do_zombie_query('not');
     $this->assertTrue($result->success);
     $this->assertEquals(array(3), $this->get_result_ids($result));
     // Search for nonexistent word.
     $result = $this->do_zombie_query('xyzzy');
     $this->assertFalse($result->success);
     $this->assertEquals('xyzzy', $result->problemword);
     // Search for nothing.
     $result = $this->do_zombie_query('   ');
     $this->assertFalse($result->success);
     $this->assertEquals('', $result->problemword);
     // Search for pair of terms.
     $result = $this->do_zombie_query('first document');
     $this->assertTrue($result->success);
     $this->assertEquals(array(1), $this->get_result_ids($result));
     // Search for quoted terms.
     $result = $this->do_zombie_query('"title title"');
     $this->assertTrue($result->success);
     $this->assertEquals(array(2), $this->get_result_ids($result));
     // Negative terms.
     $result = $this->do_zombie_query('title -not');
     $this->assertTrue($result->success);
     $this->assertEquals(array(1, 2), $this->get_result_ids($result));
     // Negative quoted terms.
     $result = $this->do_zombie_query('title -"not frog"');
     $this->assertTrue($result->success);
     $this->assertEquals(array(1, 2, 3), $this->get_result_ids($result));
     $result = $this->do_zombie_query('title -"not a"');
     $this->assertTrue($result->success);
     $this->assertEquals(array(1, 2), $this->get_result_ids($result));
     // Deleting stale results (those which the module responsible can no
     // longer find).
     $before = $DB->count_records('local_ousearch_documents');
     unset(self::$zombiedocuments[4]);
     $result = $this->do_zombie_query('delete');
     $this->assertEquals(1, count(phpunit_util::get_debugging_messages()));
     phpunit_util::reset_debugging();
     $this->assertTrue($result->success);
     $this->assertEquals(array(), $this->get_result_ids($result));
     $this->assertEquals($before - 1, $DB->count_records('local_ousearch_documents'));
     // Ranking based on title vs content and number of occurrences.
     $result = $this->do_zombie_query('title');
     $this->assertTrue($result->success);
     $this->assertEquals(array(1, 2, 3), $this->get_result_ids($result));
     $this->assertEquals(2, $result->results[0]->intref1);
     $this->assertEquals(18, $result->results[0]->totalscore);
     // Managing result lists.
     $found = array();
     $dbstart = 0;
     for ($i = 0; $i < 10; $i++) {
         $result = $this->do_zombie_query('bottles', $dbstart);
         $this->assertTrue($result->success);
         $this->assertEquals(10, count($result->results));
         foreach ($result->results as $thing) {
             $found[$thing->intref1] = true;
         }
         $dbstart = $result->dbstart;
     }
     $this->assertEquals(100, count($found));
     $result = $this->do_zombie_query('bottles', $dbstart);
     $this->assertTrue($result->success);
     $this->assertEquals(0, count($result->results));
 }
开发者ID:profcab,项目名称:moodle-local_ousearch,代码行数:80,代码来源:searchlib_test.php

示例8: test_retrieve_metadata_for_course_entity_incorrect_object_properties

 /**
  * Test retrieving course metadata with incorrect object properties
  * @param object $certsetting Certificate settings mock object
  * @param object $certissued Certificate issued mock object
  * @param object $student User mock object
  * @dataProvider incorrect_object_properties_provider
  */
 public function test_retrieve_metadata_for_course_entity_incorrect_object_properties($certsetting, $certissued, $student)
 {
     $this->load_csv_data();
     $result = certificate_get_course_entity_metadata($certsetting, $certissued, $student);
     phpunit_util::reset_debugging();
     $this->assertEquals(false, $result);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:14,代码来源:certificate_get_entity_metadata_test.php

示例9: test_class_name_helper_with_incorrect_cert_setting_data

 /**
  * Test helper method for getting the course name via certificate settings data
  * @param object $certsetting A certificatesettings object with missing properties
  * @dataProvider class_name_helper_with_incorrect_cert_setting_property_provider
  */
 public function test_class_name_helper_with_incorrect_cert_setting_data($certsetting)
 {
     $certlist = new certificatelistpage();
     $result = $certlist->get_cert_entity_name($certsetting);
     phpunit_util::reset_debugging();
     $this->assertEquals(false, $result);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:12,代码来源:certificate_list_get_class_name_by_course_test.php


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