MDL-69099 tasks: Do not mark the non-enabled plugin's task as disabled

The `core\plugininfo\base::is_enabled()` uses three-state logic for its
return value. It can return null as a valid value as per its
documentation. We need to test for the explicit false value in this
case.

To make the attached Behat test able to identify the table, the caption
is added. It seems to be helpful for all users so I leave it displayed
without using the accesshide mechanism.
This commit is contained in:
David Mudrák 2020-06-19 17:02:08 +02:00 committed by Víctor Déniz Falcón
parent 680502e4da
commit cdcb53a114
2 changed files with 8 additions and 1 deletions

View File

@ -48,6 +48,7 @@ class tool_task_renderer extends plugin_renderer_base {
$showloglink = \core\task\logmanager::has_log_report();
$table = new html_table();
$table->caption = get_string('scheduledtasks', 'tool_task');
$table->head = [
get_string('name'),
get_string('component', 'tool_task'),
@ -180,7 +181,7 @@ class tool_task_renderer extends plugin_renderer_base {
$plugininfo->init_display_name();
$componentname = $plugininfo->displayname;
if (!$plugininfo->is_enabled()) {
if ($plugininfo->is_enabled() === false) {
$componentname .= ' ' . html_writer::span(
get_string('disabled', 'tool_task'), 'badge badge-secondary');
}

View File

@ -65,3 +65,9 @@ Feature: Manage scheduled tasks
| Name | Component | Minute | Hour | Day | Day of week | Month |
| Log table cleanup | Standard log | */5 | 1 | 2 | 4 | 3 |
And I should see "Log table cleanup" in the "tr.table-primary" "css_element"
Scenario: Disabled plugin's tasks are labelled as disabled too
When "CAS users sync job \auth_cas\task\sync_task" row "Next run" column of "Scheduled tasks" table should contain "Plugin disabled"
Then "CAS users sync job \auth_cas\task\sync_task" row "Component" column of "Scheduled tasks" table should contain "Disabled"
And "Background processing for scheduled allocation \workshopallocation_scheduled\task\cron_task" row "Next run" column of "Scheduled tasks" table should not contain "Plugin disabled"
And "Background processing for scheduled allocation \workshopallocation_scheduled\task\cron_task" row "Component" column of "Scheduled tasks" table should not contain "Disabled"