[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This file contains the unittests for adhock tasks. 19 * 20 * @package core 21 * @category phpunit 22 * @copyright 2013 Damyon Wiese 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 require_once (__DIR__ . '/fixtures/task_fixtures.php'); 28 29 30 /** 31 * Test class for adhoc tasks. 32 * 33 * @package core 34 * @category task 35 * @copyright 2013 Damyon Wiese 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class core_adhoc_task_testcase extends advanced_testcase { 39 40 public function test_get_next_adhoc_task() { 41 $this->resetAfterTest(true); 42 // Create an adhoc task. 43 $task = new \core\task\adhoc_test_task(); 44 45 // Queue it. 46 $task = \core\task\manager::queue_adhoc_task($task); 47 48 $now = time(); 49 // Get it from the scheduler. 50 $task = \core\task\manager::get_next_adhoc_task($now); 51 $this->assertNotNull($task); 52 $task->execute(); 53 54 \core\task\manager::adhoc_task_failed($task); 55 // Should not get any task. 56 $task = \core\task\manager::get_next_adhoc_task($now); 57 $this->assertNull($task); 58 59 // Should get the adhoc task (retry after delay). 60 $task = \core\task\manager::get_next_adhoc_task($now + 120); 61 $this->assertNotNull($task); 62 $task->execute(); 63 64 \core\task\manager::adhoc_task_complete($task); 65 66 // Should not get any task. 67 $task = \core\task\manager::get_next_adhoc_task($now); 68 $this->assertNull($task); 69 } 70 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |