Línea 24... |
Línea 24... |
24 |
*
|
24 |
*
|
25 |
* @package core
|
25 |
* @package core
|
26 |
* @category test
|
26 |
* @category test
|
27 |
* @copyright 2013 Damyon Wiese
|
27 |
* @copyright 2013 Damyon Wiese
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
29 |
* @coversDefaultClass \core\task\scheduled_task
|
29 |
* @covers \core\task\scheduled_task
|
30 |
*/
|
30 |
*/
|
31 |
class scheduled_task_test extends \advanced_testcase {
|
31 |
final class scheduled_task_test extends \advanced_testcase {
|
Línea 32... |
Línea 32... |
32 |
|
32 |
|
33 |
/**
|
33 |
/**
|
34 |
* Data provider for {@see test_eval_cron_field}
|
34 |
* Data provider for {@see test_eval_cron_field}
|
35 |
*
|
35 |
*
|
Línea 63... |
Línea 63... |
63 |
* @param int $min
|
63 |
* @param int $min
|
64 |
* @param int $max
|
64 |
* @param int $max
|
65 |
* @param int[] $expected
|
65 |
* @param int[] $expected
|
66 |
*
|
66 |
*
|
67 |
* @dataProvider eval_cron_provider
|
67 |
* @dataProvider eval_cron_provider
|
68 |
*
|
- |
|
69 |
* @covers ::eval_cron_field
|
- |
|
70 |
*/
|
68 |
*/
|
71 |
public function test_eval_cron_field(string $field, int $min, int $max, array $expected): void {
|
69 |
public function test_eval_cron_field(string $field, int $min, int $max, array $expected): void {
|
72 |
$testclass = new scheduled_test_task();
|
70 |
$testclass = new scheduled_test_task();
|
Línea 73... |
Línea 71... |
73 |
|
71 |
|
74 |
$this->assertEquals($expected, $testclass->eval_cron_field($field, $min, $max));
|
72 |
$this->assertEquals($expected, $testclass->eval_cron_field($field, $min, $max));
|
Línea 75... |
Línea 73... |
75 |
}
|
73 |
}
|
76 |
|
- |
|
77 |
public function test_get_next_scheduled_time(): void {
|
74 |
|
Línea 78... |
Línea -... |
78 |
global $CFG;
|
- |
|
79 |
$this->resetAfterTest();
|
- |
|
80 |
|
- |
|
81 |
$this->setTimezone('Europe/London');
|
- |
|
82 |
|
- |
|
83 |
// Let's specify the hour we are going to use initially for the test.
|
- |
|
84 |
// (note that we pick 01:00 that is tricky for Europe/London, because
|
- |
|
85 |
// it's exactly the Daylight Saving Time Begins hour.
|
- |
|
86 |
$testhour = 1;
|
- |
|
87 |
|
- |
|
88 |
// Test job run at 1 am.
|
- |
|
89 |
$testclass = new scheduled_test_task();
|
- |
|
90 |
|
- |
|
91 |
// All fields default to '*'.
|
- |
|
92 |
$testclass->set_hour($testhour);
|
- |
|
93 |
$testclass->set_minute('0');
|
- |
|
94 |
// Next valid time should be 1am of the next day.
|
- |
|
95 |
$nexttime = $testclass->get_next_scheduled_time();
|
- |
|
96 |
|
- |
|
97 |
$oneamdate = new \DateTime('now', new \DateTimeZone('Europe/London'));
|
- |
|
98 |
$oneamdate->setTime($testhour, 0, 0);
|
- |
|
99 |
|
- |
|
100 |
// Once a year (currently last Sunday of March), when changing to Daylight Saving Time,
|
- |
|
101 |
// Europe/London 01:00 simply doesn't exists because, exactly at 01:00 the clock
|
- |
|
102 |
// is advanced by one hour and becomes 02:00. When that happens, the DateInterval
|
- |
|
103 |
// calculations cannot be to advance by 1 day, but by one less hour. That is exactly when
|
- |
|
104 |
// the next scheduled run will happen (next day 01:00).
|
- |
|
105 |
$isdaylightsaving = false;
|
- |
|
106 |
if ($testhour < (int)$oneamdate->format('H')) {
|
- |
|
107 |
$isdaylightsaving = true;
|
- |
|
108 |
}
|
- |
|
109 |
|
- |
|
110 |
// Make it 1 am tomorrow if the time is after 1am.
|
- |
|
111 |
if ($oneamdate->getTimestamp() < time()) {
|
- |
|
112 |
$oneamdate->add(new \DateInterval('P1D'));
|
- |
|
113 |
if ($isdaylightsaving) {
|
- |
|
114 |
// If today is Europe/London Daylight Saving Time Begins, expectation is 1 less hour.
|
- |
|
115 |
$oneamdate->sub(new \DateInterval('PT1H'));
|
- |
|
116 |
}
|
- |
|
117 |
}
|
- |
|
118 |
$oneam = $oneamdate->getTimestamp();
|
- |
|
119 |
|
- |
|
120 |
$this->assertEquals($oneam, $nexttime, 'Next scheduled time is 1am.');
|
- |
|
121 |
|
- |
|
122 |
// Disabled flag does not affect next time.
|
- |
|
123 |
$testclass->set_disabled(true);
|
- |
|
124 |
$nexttime = $testclass->get_next_scheduled_time();
|
75 |
public function test_get_next_scheduled_time(): void {
|
125 |
$this->assertEquals($oneam, $nexttime, 'Next scheduled time is 1am.');
|
76 |
$this->resetAfterTest();
|
Línea 126... |
Línea 77... |
126 |
|
77 |
|
127 |
// Now test for job run every 10 minutes.
|
78 |
// Test for job run every 10 minutes.
|
128 |
$testclass = new scheduled_test_task();
|
79 |
$testclass = new scheduled_test_task();
|
Línea 240... |
Línea 191... |
240 |
* @param string $day Day restriction list for task
|
191 |
* @param string $day Day restriction list for task
|
241 |
* @param string $dayofweek Day of week restriction list for task
|
192 |
* @param string $dayofweek Day of week restriction list for task
|
242 |
* @param string $month Month restriction list for task
|
193 |
* @param string $month Month restriction list for task
|
243 |
* @param string|int $expected Expected run time (strtotime format or time int)
|
194 |
* @param string|int $expected Expected run time (strtotime format or time int)
|
244 |
* @dataProvider get_next_scheduled_time_detail_provider
|
195 |
* @dataProvider get_next_scheduled_time_detail_provider
|
245 |
* @covers ::get_next_scheduled_time
|
- |
|
246 |
*/
|
196 |
*/
|
247 |
public function test_get_next_scheduled_time_detail(string $now, string $minute, string $hour,
|
197 |
public function test_get_next_scheduled_time_detail(string $now, string $minute, string $hour,
|
248 |
string $day, string $dayofweek, string $month, string|int $expected): void {
|
198 |
string $day, string $dayofweek, string $month, string|int $expected): void {
|
249 |
// Create test task with specified times.
|
199 |
// Create test task with specified times.
|
250 |
$task = new scheduled_test_task();
|
200 |
$task = new scheduled_test_task();
|
Línea 269... |
Línea 219... |
269 |
* Tests get_next_scheduled_time around DST changes, with regard to the continuity of frequent
|
219 |
* Tests get_next_scheduled_time around DST changes, with regard to the continuity of frequent
|
270 |
* tasks.
|
220 |
* tasks.
|
271 |
*
|
221 |
*
|
272 |
* We want frequent tasks to keep progressing as normal and not randomly stop for an hour, or
|
222 |
* We want frequent tasks to keep progressing as normal and not randomly stop for an hour, or
|
273 |
* suddenly decide they need to happen in the past.
|
223 |
* suddenly decide they need to happen in the past.
|
274 |
*
|
- |
|
275 |
* @covers ::get_next_scheduled_time
|
- |
|
276 |
*/
|
224 |
*/
|
277 |
public function test_get_next_scheduled_time_dst_continuity(): void {
|
225 |
public function test_get_next_scheduled_time_dst_continuity(): void {
|
278 |
$this->resetAfterTest();
|
226 |
$this->resetAfterTest();
|
279 |
$this->setTimezone('Europe/London');
|
227 |
$this->setTimezone('Europe/London');
|
Línea 310... |
Línea 258... |
310 |
$this->assertEquals(strtotime('2023-10-29 02:00 GMT'), $four);
|
258 |
$this->assertEquals(strtotime('2023-10-29 02:00 GMT'), $four);
|
311 |
// This time is now unambiguous in Europe/London.
|
259 |
// This time is now unambiguous in Europe/London.
|
312 |
$this->assertEquals(strtotime('2023-10-29 02:00 Europe/London'), $four);
|
260 |
$this->assertEquals(strtotime('2023-10-29 02:00 Europe/London'), $four);
|
313 |
}
|
261 |
}
|
Línea -... |
Línea 262... |
- |
|
262 |
|
- |
|
263 |
/**
|
- |
|
264 |
* Tests get_next_scheduled_time for tasks set to run at the hour the time changes
|
- |
|
265 |
* for Daylight Saving Time.
|
- |
|
266 |
*/
|
- |
|
267 |
public function test_get_next_scheduled_time_dst_hour(): void {
|
- |
|
268 |
$this->resetAfterTest();
|
- |
|
269 |
|
- |
|
270 |
// Check a timezone where the clock change happens at 1am.
|
- |
|
271 |
$this->setTimezone('Europe/London');
|
- |
|
272 |
// Test task is set to run every day at 1am and 3am.
|
- |
|
273 |
$task = new scheduled_test_task();
|
- |
|
274 |
$task->set_hour('1, 3');
|
- |
|
275 |
$task->set_minute('0');
|
- |
|
276 |
|
- |
|
277 |
// DST change forwards. Check times in GMT to ensure it progresses as normal.
|
- |
|
278 |
$now = strtotime('2025-03-30 00:59 GMT');
|
- |
|
279 |
$this->assertEquals(strtotime('2025-03-30 00:59 Europe/London'), $now);
|
- |
|
280 |
$nexttime = $task->get_next_scheduled_time($now);
|
- |
|
281 |
$this->assertEquals(strtotime('2025-03-30 01:00 GMT'), $nexttime);
|
- |
|
282 |
$this->assertEquals(strtotime('2025-03-30 02:00 Europe/London'), $nexttime);
|
- |
|
283 |
|
- |
|
284 |
// Check the next run is at 3am.
|
- |
|
285 |
$nexttime = $task->get_next_scheduled_time($nexttime);
|
- |
|
286 |
$this->assertEquals(strtotime('2025-03-30 02:00 GMT'), $nexttime);
|
- |
|
287 |
$this->assertEquals(strtotime('2025-03-30 03:00 Europe/London'), $nexttime);
|
- |
|
288 |
|
- |
|
289 |
// Test task is set to run every day at 1am.
|
- |
|
290 |
$task = new scheduled_test_task();
|
- |
|
291 |
$task->set_hour('1');
|
- |
|
292 |
$task->set_minute('0');
|
- |
|
293 |
|
- |
|
294 |
// DST change backwards.
|
- |
|
295 |
$now = strtotime('2025-10-25 00:01 GMT');
|
- |
|
296 |
$this->assertEquals(strtotime('2025-10-25 01:01 Europe/London'), $now);
|
- |
|
297 |
$nexttime = $task->get_next_scheduled_time($now);
|
- |
|
298 |
// The next time is 1:00 Europe/London, but we won't explicitly test that because
|
- |
|
299 |
// there are two 1:00s so it might fail depending on implementation.
|
- |
|
300 |
$this->assertEquals(strtotime('2025-10-26 01:00 GMT'), $nexttime);
|
- |
|
301 |
|
- |
|
302 |
// Check a timezone where the clock change happens at midnight.
|
- |
|
303 |
$this->setTimezone('Africa/Cairo');
|
- |
|
304 |
// Test task is set to run every day at midnight and 3am.
|
- |
|
305 |
$task = new scheduled_test_task();
|
- |
|
306 |
$task->set_hour('0, 3');
|
- |
|
307 |
$task->set_minute('0');
|
- |
|
308 |
|
- |
|
309 |
// DST change forwards. Check times in GMT to ensure it progresses as normal.
|
- |
|
310 |
$now = strtotime('2025-04-24 23:59 GMT+2');
|
- |
|
311 |
$this->assertEquals(strtotime('2025-04-24 23:59 Africa/Cairo'), $now);
|
- |
|
312 |
$nexttime = $task->get_next_scheduled_time($now);
|
- |
|
313 |
$this->assertEquals(strtotime('2025-04-25 00:00 GMT+2'), $nexttime);
|
- |
|
314 |
$this->assertEquals(strtotime('2025-04-25 01:00 Africa/Cairo'), $nexttime);
|
- |
|
315 |
|
- |
|
316 |
// Test task is set to run every day at 11pm.
|
- |
|
317 |
$task = new scheduled_test_task();
|
- |
|
318 |
$task->set_hour('23');
|
- |
|
319 |
$task->set_minute('0');
|
- |
|
320 |
|
- |
|
321 |
// DST change backwards.
|
- |
|
322 |
$now = strtotime('2025-10-29 23:01 GMT+3');
|
- |
|
323 |
$this->assertEquals(strtotime('2025-10-29 23:01 Africa/Cairo'), $now);
|
- |
|
324 |
$nexttime = $task->get_next_scheduled_time($now);
|
- |
|
325 |
// The next time is 00:00 Africa/Cairo, but we won't explicitly test that because
|
- |
|
326 |
// there are two 00:00s so it might fail depending on implementation.
|
- |
|
327 |
$this->assertEquals(strtotime('2025-10-30 23:00 GMT+2'), $nexttime);
|
- |
|
328 |
}
|
- |
|
329 |
|
- |
|
330 |
/**
|
- |
|
331 |
* Tests get_next_scheduled_time for tasks set to run at minute intervals during
|
- |
|
332 |
* the hour the time changes for Daylight Saving Time.
|
- |
|
333 |
*/
|
- |
|
334 |
public function test_get_next_scheduled_time_dst_hour_minute(): void {
|
- |
|
335 |
$this->resetAfterTest();
|
- |
|
336 |
|
- |
|
337 |
// Check a timezone where the clock change happens at 1am.
|
- |
|
338 |
$this->setTimezone('Europe/London');
|
- |
|
339 |
// Test task is set to run every day at 1:00, 1:20, 1:40.
|
- |
|
340 |
$task = new scheduled_test_task();
|
- |
|
341 |
$task->set_hour('1');
|
- |
|
342 |
$task->set_minute('*/20');
|
- |
|
343 |
|
- |
|
344 |
// DST change forwards. 1am doesn't exist so the runs happen during the following hour.
|
- |
|
345 |
$before = strtotime('2025-03-30 00:59 GMT');
|
- |
|
346 |
$this->assertEquals(strtotime('2025-03-30 00:59 Europe/London'), $before);
|
- |
|
347 |
$one = $task->get_next_scheduled_time($before);
|
- |
|
348 |
$this->assertEquals(strtotime('2025-03-30 02:00 Europe/London'), $one);
|
- |
|
349 |
$two = $task->get_next_scheduled_time($one);
|
- |
|
350 |
$this->assertEquals(strtotime('2025-03-30 02:20 Europe/London'), $two);
|
- |
|
351 |
$three = $task->get_next_scheduled_time($two);
|
- |
|
352 |
$this->assertEquals(strtotime('2025-03-30 02:40 Europe/London'), $three);
|
- |
|
353 |
$four = $task->get_next_scheduled_time($three);
|
- |
|
354 |
$this->assertEquals(strtotime('2025-03-31 01:00 Europe/London'), $four);
|
- |
|
355 |
|
- |
|
356 |
// DST change backwards. 1am happens twice, but we only expect the runs to happen during
|
- |
|
357 |
// the second occurrence.
|
- |
|
358 |
$before = strtotime('2025-10-25 23:59 GMT');
|
- |
|
359 |
$this->assertEquals(strtotime('2025-10-26 00:59 Europe/London'), $before);
|
- |
|
360 |
// The next 3 times happen during the second occurrence of 01:00 Europe/London, but we
|
- |
|
361 |
// won't explicitly test that because there are two 01:00s so it might fail depending
|
- |
|
362 |
// on implementation.
|
- |
|
363 |
$one = $task->get_next_scheduled_time($before);
|
- |
|
364 |
$this->assertEquals(strtotime('2025-10-26 01:00 GMT'), $one);
|
- |
|
365 |
$two = $task->get_next_scheduled_time($one);
|
- |
|
366 |
$this->assertEquals(strtotime('2025-10-26 01:20 GMT'), $two);
|
- |
|
367 |
$three = $task->get_next_scheduled_time($two);
|
- |
|
368 |
$this->assertEquals(strtotime('2025-10-26 01:40 GMT'), $three);
|
- |
|
369 |
$four = $task->get_next_scheduled_time($three);
|
- |
|
370 |
$this->assertEquals(strtotime('2025-10-27 1:00 GMT'), $four);
|
- |
|
371 |
$this->assertEquals(strtotime('2025-10-27 1:00 Europe/London'), $four);
|
- |
|
372 |
|
- |
|
373 |
// Test task is set to run every thirty minutes over the time change - midnight to 3am.
|
- |
|
374 |
$task = new scheduled_test_task();
|
- |
|
375 |
$task->set_hour('0,1,2,3');
|
- |
|
376 |
$task->set_minute('*/30');
|
- |
|
377 |
|
- |
|
378 |
// DST change forwards. We expect 1am to be skipped, but not replaced by the next hour
|
- |
|
379 |
// as the task will run anyway during 2am.
|
- |
|
380 |
$before = strtotime('2025-03-29 23:59 GMT');
|
- |
|
381 |
$this->assertEquals(strtotime('2025-03-29 23:59 Europe/London'), $before);
|
- |
|
382 |
$midnight = $task->get_next_scheduled_time($before);
|
- |
|
383 |
$this->assertEquals(strtotime('2025-03-30 00:00 Europe/London'), $midnight);
|
- |
|
384 |
$midnightb = $task->get_next_scheduled_time($midnight);
|
- |
|
385 |
$this->assertEquals(strtotime('2025-03-30 00:30 Europe/London'), $midnightb);
|
- |
|
386 |
// 1am is skipped because it doesn't exist.
|
- |
|
387 |
$two = $task->get_next_scheduled_time($midnightb);
|
- |
|
388 |
$this->assertEquals(strtotime('2025-03-30 02:00 Europe/London'), $two);
|
- |
|
389 |
$twob = $task->get_next_scheduled_time($two);
|
- |
|
390 |
$this->assertEquals(strtotime('2025-03-30 02:30 Europe/London'), $twob);
|
- |
|
391 |
$three = $task->get_next_scheduled_time($twob);
|
- |
|
392 |
$this->assertEquals(strtotime('2025-03-30 03:00 Europe/London'), $three);
|
- |
|
393 |
$threeb = $task->get_next_scheduled_time($three);
|
- |
|
394 |
$this->assertEquals(strtotime('2025-03-30 03:30 Europe/London'), $threeb);
|
- |
|
395 |
$nextday = $task->get_next_scheduled_time($threeb);
|
- |
|
396 |
$this->assertEquals(strtotime('2025-03-31 00:00 Europe/London'), $nextday);
|
- |
|
397 |
|
- |
|
398 |
// DST change backwards. A bit of a weird one - the task actually runs for an extra
|
- |
|
399 |
// hour because 1am happens twice.
|
- |
|
400 |
$before = strtotime('2025-10-25 22:59 GMT');
|
- |
|
401 |
$this->assertEquals(strtotime('2025-10-25 23:59 Europe/London'), $before);
|
- |
|
402 |
$midnight = $task->get_next_scheduled_time($before);
|
- |
|
403 |
$this->assertEquals(strtotime('2025-10-25 23:00 GMT'), $midnight);
|
- |
|
404 |
$this->assertEquals(strtotime('2025-10-26 00:00 Europe/London'), $midnight);
|
- |
|
405 |
$midnightb = $task->get_next_scheduled_time($midnight);
|
- |
|
406 |
$this->assertEquals(strtotime('2025-10-25 23:30 GMT'), $midnightb);
|
- |
|
407 |
$this->assertEquals(strtotime('2025-10-26 00:30 Europe/London'), $midnightb);
|
- |
|
408 |
$one = $task->get_next_scheduled_time($midnightb);
|
- |
|
409 |
// The next 4 times happen during 01:00 Europe/London, but we won't explicitly test that
|
- |
|
410 |
// because there are two 01:00s so it might fail depending on implementation.
|
- |
|
411 |
$this->assertEquals(strtotime('2025-10-26 00:00 GMT'), $one);
|
- |
|
412 |
$oneb = $task->get_next_scheduled_time($one);
|
- |
|
413 |
$this->assertEquals(strtotime('2025-10-26 00:30 GMT'), $oneb);
|
- |
|
414 |
// 1am happens again because of the hour change.
|
- |
|
415 |
$oneagain = $task->get_next_scheduled_time($oneb);
|
- |
|
416 |
$this->assertEquals(strtotime('2025-10-26 01:00 GMT'), $oneagain);
|
- |
|
417 |
$oneagainb = $task->get_next_scheduled_time($oneagain);
|
- |
|
418 |
$this->assertEquals(strtotime('2025-10-26 01:30 GMT'), $oneagainb);
|
- |
|
419 |
// Times are now unambiguous in Europe/London.
|
- |
|
420 |
$two = $task->get_next_scheduled_time($oneagainb);
|
- |
|
421 |
$this->assertEquals(strtotime('2025-10-26 02:00 GMT'), $two);
|
- |
|
422 |
$this->assertEquals(strtotime('2025-10-26 02:00 Europe/London'), $two);
|
- |
|
423 |
$twob = $task->get_next_scheduled_time($two);
|
- |
|
424 |
$this->assertEquals(strtotime('2025-10-26 02:30 Europe/London'), $twob);
|
- |
|
425 |
$three = $task->get_next_scheduled_time($twob);
|
- |
|
426 |
$this->assertEquals(strtotime('2025-10-26 03:00 Europe/London'), $three);
|
- |
|
427 |
$threeb = $task->get_next_scheduled_time($three);
|
- |
|
428 |
$this->assertEquals(strtotime('2025-10-26 03:30 Europe/London'), $threeb);
|
- |
|
429 |
$nextday = $task->get_next_scheduled_time($threeb);
|
- |
|
430 |
$this->assertEquals(strtotime('2025-10-27 00:00 Europe/London'), $nextday);
|
- |
|
431 |
}
|
314 |
|
432 |
|
315 |
public function test_timezones(): void {
|
433 |
public function test_timezones(): void {
|
Línea 316... |
Línea 434... |
316 |
global $CFG, $USER;
|
434 |
global $CFG, $USER;
|
317 |
|
435 |
|
Línea 712... |
Línea 830... |
712 |
* Data provider for test_scheduled_task_override_values.
|
830 |
* Data provider for test_scheduled_task_override_values.
|
713 |
*/
|
831 |
*/
|
714 |
public static function provider_schedule_overrides(): array {
|
832 |
public static function provider_schedule_overrides(): array {
|
715 |
return array(
|
833 |
return array(
|
716 |
array(
|
834 |
array(
|
717 |
'scheduled_tasks' => array(
|
835 |
'overrides' => array(
|
718 |
'\core\task\scheduled_test_task' => array(
|
836 |
'\core\task\scheduled_test_task' => array(
|
719 |
'schedule' => '10 13 1 2 4',
|
837 |
'schedule' => '10 13 1 2 4',
|
720 |
'disabled' => 0,
|
838 |
'disabled' => 0,
|
721 |
),
|
839 |
),
|
722 |
'\core\task\scheduled_test2_task' => array(
|
840 |
'\core\task\scheduled_test2_task' => array(
|
723 |
'schedule' => '* * * * *',
|
841 |
'schedule' => '* * * * *',
|
724 |
'disabled' => 1,
|
842 |
'disabled' => 1,
|
725 |
),
|
843 |
),
|
726 |
),
|
844 |
),
|
727 |
'task_full_classnames' => array(
|
845 |
'tasks' => array(
|
728 |
'\core\task\scheduled_test_task',
|
846 |
'\core\task\scheduled_test_task',
|
729 |
'\core\task\scheduled_test2_task',
|
847 |
'\core\task\scheduled_test2_task',
|
730 |
),
|
848 |
),
|
731 |
'expected' => array(
|
849 |
'expected' => array(
|
732 |
'\core\task\scheduled_test_task' => array(
|
850 |
'\core\task\scheduled_test_task' => array(
|
Línea 746... |
Línea 864... |
746 |
'disabled' => 1,
|
864 |
'disabled' => 1,
|
747 |
),
|
865 |
),
|
748 |
)
|
866 |
)
|
749 |
),
|
867 |
),
|
750 |
array(
|
868 |
array(
|
751 |
'scheduled_tasks' => array(
|
869 |
'overrides' => array(
|
752 |
'\core\task\*' => array(
|
870 |
'\core\task\*' => array(
|
753 |
'schedule' => '1 2 3 4 5',
|
871 |
'schedule' => '1 2 3 4 5',
|
754 |
'disabled' => 0,
|
872 |
'disabled' => 0,
|
755 |
)
|
873 |
)
|
756 |
),
|
874 |
),
|
757 |
'task_full_classnames' => array(
|
875 |
'tasks' => array(
|
758 |
'\core\task\scheduled_test_task',
|
876 |
'\core\task\scheduled_test_task',
|
759 |
'\core\task\scheduled_test2_task',
|
877 |
'\core\task\scheduled_test2_task',
|
760 |
),
|
878 |
),
|
761 |
'expected' => array(
|
879 |
'expected' => array(
|
762 |
'\core\task\scheduled_test_task' => array(
|
880 |
'\core\task\scheduled_test_task' => array(
|
Línea 947... |
Línea 1065... |
947 |
/**
|
1065 |
/**
|
948 |
* Data provider for {@see test_is_component_enabled}
|
1066 |
* Data provider for {@see test_is_component_enabled}
|
949 |
*
|
1067 |
*
|
950 |
* @return array[]
|
1068 |
* @return array[]
|
951 |
*/
|
1069 |
*/
|
952 |
public function is_component_enabled_provider(): array {
|
1070 |
public static function is_component_enabled_provider(): array {
|
953 |
return [
|
1071 |
return [
|
954 |
'Enabled component' => ['auth_cas', true],
|
1072 |
'Enabled component' => ['auth_email', true],
|
955 |
'Disabled component' => ['auth_ldap', false],
|
1073 |
'Disabled component' => ['auth_ldap', false],
|
956 |
'Invalid component' => ['auth_invalid', false],
|
1074 |
'Invalid component' => ['auth_invalid', false],
|
957 |
];
|
1075 |
];
|
958 |
}
|
1076 |
}
|
Línea 967... |
Línea 1085... |
967 |
*/
|
1085 |
*/
|
968 |
public function test_is_component_enabled(string $component, bool $expected): void {
|
1086 |
public function test_is_component_enabled(string $component, bool $expected): void {
|
969 |
$this->resetAfterTest();
|
1087 |
$this->resetAfterTest();
|
Línea 970... |
Línea 1088... |
970 |
|
1088 |
|
971 |
// Set cas as the only enabled auth component.
|
1089 |
// Set cas as the only enabled auth component.
|
Línea 972... |
Línea 1090... |
972 |
set_config('auth', 'cas');
|
1090 |
set_config('auth', 'email');
|
973 |
|
1091 |
|
Línea 974... |
Línea 1092... |
974 |
$task = new scheduled_test_task();
|
1092 |
$task = new scheduled_test_task();
|
Línea 985... |
Línea 1103... |
985 |
$this->assertTrue($task->is_component_enabled());
|
1103 |
$this->assertTrue($task->is_component_enabled());
|
986 |
}
|
1104 |
}
|
Línea 987... |
Línea 1105... |
987 |
|
1105 |
|
988 |
/**
|
1106 |
/**
|
989 |
* Test disabling and enabling individual tasks.
|
- |
|
990 |
*
|
- |
|
991 |
* @covers ::disable
|
- |
|
992 |
* @covers ::enable
|
- |
|
993 |
* @covers ::has_default_configuration
|
1107 |
* Test disabling and enabling individual tasks.
|
994 |
*/
|
1108 |
*/
|
995 |
public function test_disable_and_enable_task(): void {
|
1109 |
public function test_disable_and_enable_task(): void {
|
Línea 996... |
Línea 1110... |
996 |
$this->resetAfterTest();
|
1110 |
$this->resetAfterTest();
|
Línea 1036... |
Línea 1150... |
1036 |
$this->assertEquals(false, $task->has_default_configuration());
|
1150 |
$this->assertEquals(false, $task->has_default_configuration());
|
1037 |
}
|
1151 |
}
|
Línea 1038... |
Línea 1152... |
1038 |
|
1152 |
|
1039 |
/**
|
1153 |
/**
|
1040 |
* Test send messages when a task reaches the max fail delay time.
|
- |
|
1041 |
*
|
- |
|
1042 |
* @covers ::scheduled_task_failed
|
- |
|
1043 |
* @covers ::send_failed_task_max_delay_message
|
1154 |
* Test send messages when a task reaches the max fail delay time.
|
1044 |
*/
|
1155 |
*/
|
1045 |
public function test_message_max_fail_delay(): void {
|
1156 |
public function test_message_max_fail_delay(): void {
|
1046 |
$this->resetAfterTest();
|
1157 |
$this->resetAfterTest();
|