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


PHP manager::load_scheduled_tasks_for_component方法代码示例

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


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

示例1: test_reset_scheduled_tasks_for_component

    public function test_reset_scheduled_tasks_for_component() {
        global $DB;

        $this->resetAfterTest(true);
        // Remember the defaults.
        $defaulttasks = \core\task\manager::load_scheduled_tasks_for_component('moodle');
        $initcount = count($defaulttasks);
        // Customise a task.
        $firsttask = reset($defaulttasks);
        $firsttask->set_minute('1');
        $firsttask->set_hour('2');
        $firsttask->set_month('3');
        $firsttask->set_day_of_week('4');
        $firsttask->set_day('5');
        $firsttask->set_customised('1');
        \core\task\manager::configure_scheduled_task($firsttask);
        $firsttaskrecord = \core\task\manager::record_from_scheduled_task($firsttask);
        // We reset this field, because we do not want to compare it.
        $firsttaskrecord->nextruntime = '0';

        // Now call reset on all the tasks.
        \core\task\manager::reset_scheduled_tasks_for_component('moodle');

        // Load the tasks again.
        $defaulttasks = \core\task\manager::load_scheduled_tasks_for_component('moodle');
        $finalcount = count($defaulttasks);
        // Compare the first task.
        $newfirsttask = reset($defaulttasks);
        $newfirsttaskrecord = \core\task\manager::record_from_scheduled_task($newfirsttask);
        // We reset this field, because we do not want to compare it.
        $newfirsttaskrecord->nextruntime = '0';

        // Assert a customised task was not altered by reset.
        $this->assertEquals($firsttaskrecord, $newfirsttaskrecord);

        // Assert we have the same number of tasks.
        $this->assertEquals($initcount, $finalcount);
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:38,代码来源:scheduled_task_test.php

示例2: test_reset_scheduled_tasks_for_component

 public function test_reset_scheduled_tasks_for_component()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Remember the defaults.
     $defaulttasks = \core\task\manager::load_scheduled_tasks_for_component('moodle');
     $initcount = count($defaulttasks);
     // Customise a task.
     $firsttask = reset($defaulttasks);
     $firsttask->set_minute('1');
     $firsttask->set_hour('2');
     $firsttask->set_month('3');
     $firsttask->set_day_of_week('4');
     $firsttask->set_day('5');
     $firsttask->set_customised('1');
     \core\task\manager::configure_scheduled_task($firsttask);
     $firsttaskrecord = \core\task\manager::record_from_scheduled_task($firsttask);
     // We reset this field, because we do not want to compare it.
     $firsttaskrecord->nextruntime = '0';
     // Delete a task to simulate the fact that its new.
     $secondtask = next($defaulttasks);
     $DB->delete_records('task_scheduled', array('classname' => '\\' . trim(get_class($secondtask), '\\')));
     $this->assertFalse(\core\task\manager::get_scheduled_task(get_class($secondtask)));
     // Edit a task to simulate a change in its definition (as if it was not customised).
     $thirdtask = next($defaulttasks);
     $thirdtask->set_minute('1');
     $thirdtask->set_hour('2');
     $thirdtask->set_month('3');
     $thirdtask->set_day_of_week('4');
     $thirdtask->set_day('5');
     $thirdtaskbefore = \core\task\manager::get_scheduled_task(get_class($thirdtask));
     $thirdtaskbefore->set_next_run_time(null);
     // Ignore this value when comparing.
     \core\task\manager::configure_scheduled_task($thirdtask);
     $thirdtask = \core\task\manager::get_scheduled_task(get_class($thirdtask));
     $thirdtask->set_next_run_time(null);
     // Ignore this value when comparing.
     $this->assertNotEquals($thirdtaskbefore, $thirdtask);
     // Now call reset on all the tasks.
     \core\task\manager::reset_scheduled_tasks_for_component('moodle');
     // Load the tasks again.
     $defaulttasks = \core\task\manager::load_scheduled_tasks_for_component('moodle');
     $finalcount = count($defaulttasks);
     // Compare the first task.
     $newfirsttask = reset($defaulttasks);
     $newfirsttaskrecord = \core\task\manager::record_from_scheduled_task($newfirsttask);
     // We reset this field, because we do not want to compare it.
     $newfirsttaskrecord->nextruntime = '0';
     // Assert a customised task was not altered by reset.
     $this->assertEquals($firsttaskrecord, $newfirsttaskrecord);
     // Assert that the second task was added back.
     $secondtaskafter = \core\task\manager::get_scheduled_task(get_class($secondtask));
     $secondtaskafter->set_next_run_time(null);
     // Do not compare the nextruntime.
     $secondtask->set_next_run_time(null);
     $this->assertEquals($secondtask, $secondtaskafter);
     // Assert that the third task edits were overridden.
     $thirdtaskafter = \core\task\manager::get_scheduled_task(get_class($thirdtask));
     $thirdtaskafter->set_next_run_time(null);
     $this->assertEquals($thirdtaskbefore, $thirdtaskafter);
     // Assert we have the same number of tasks.
     $this->assertEquals($initcount, $finalcount);
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:63,代码来源:scheduled_task_test.php


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