diff --git a/admin/tool/task/renderer.php b/admin/tool/task/renderer.php index 5c8366395e2..554440015b0 100644 --- a/admin/tool/task/renderer.php +++ b/admin/tool/task/renderer.php @@ -274,7 +274,7 @@ class tool_task_renderer extends plugin_renderer_base { $nextruntime = $task->get_next_run_time(); $due = $nextruntime < $now; if ($task->get_attempts_available() > 0) { - $nextrun = $due ? userdate($nextruntime) : get_string('asap', 'tool_task'); + $nextrun = $due ? get_string('asap', 'tool_task') : userdate($nextruntime); } else { $nextrun = get_string('never', 'admin'); } diff --git a/admin/tool/task/tests/behat/adhoc_tasks.feature b/admin/tool/task/tests/behat/adhoc_tasks.feature new file mode 100644 index 00000000000..6161f609713 --- /dev/null +++ b/admin/tool/task/tests/behat/adhoc_tasks.feature @@ -0,0 +1,23 @@ +@tool @tool_task @javascript +Feature: Manage adhoc task + In order to manage adhoc tasks + As an admin + I need to be able to view adhoc tasks + + Scenario Outline: View adhoc tasks next run time + Given the following "tool_task > adhoc tasks" exist: + | classname | seconds | hostname | pid | nextruntime | + | \core\task\asynchronous_backup_task | 0 | c69335460f7f | 1915 | | + When I log in as "admin" + And I navigate to "Server > Tasks > Ad hoc tasks" in site administration + Then the following should exist in the "Ad hoc tasks" table: + | Component / Class name | Next run | + | asynchronous_backup_task | | + And I click on "asynchronous_backup_task" "link" in the "Ad hoc tasks" "table" + And the following should exist in the "\core\task\asynchronous_backup_task Ad hoc tasks" table: + | Next run | + | | + Examples: + | nextruntime | nextruntimestr | + | ##yesterday## | ASAP | + | ##tomorrow noon## | ##tomorrow noon##%A, %d %B %Y, %I:%M## | diff --git a/admin/tool/task/tests/generator/lib.php b/admin/tool/task/tests/generator/lib.php index b9324c5db60..8a822d6033f 100644 --- a/admin/tool/task/tests/generator/lib.php +++ b/admin/tool/task/tests/generator/lib.php @@ -43,7 +43,7 @@ class tool_task_generator extends testing_module_generator { global $DB; $conditions = ['classname' => $data['classname']]; $record = $DB->get_record('task_scheduled', $conditions, '*', MUST_EXIST); - $record->timestarted = time() - $data['seconds']; + $record->timestarted = $data['seconds'] > 0 ? time() - $data['seconds'] : 0; $record->hostname = $data['hostname']; $record->pid = $data['pid']; $DB->update_record('task_scheduled', $record); @@ -59,8 +59,8 @@ class tool_task_generator extends testing_module_generator { global $DB; $adhoctask = (object)[ 'classname' => $data['classname'], - 'nextruntime' => 0, - 'timestarted' => time() - $data['seconds'], + 'nextruntime' => $data['nextruntime'] ?? 0, + 'timestarted' => $data['seconds'] > 0 ? time() - $data['seconds'] : 0, 'hostname' => $data['hostname'], 'pid' => $data['pid'], ];