From cdcb53a114a59024aa6cd3de6fea3459494de857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Fri, 19 Jun 2020 17:02:08 +0200 Subject: [PATCH] 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. --- admin/tool/task/renderer.php | 3 ++- admin/tool/task/tests/behat/manage_tasks.feature | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/tool/task/renderer.php b/admin/tool/task/renderer.php index a003eab27a8..ec0bb0cac4a 100644 --- a/admin/tool/task/renderer.php +++ b/admin/tool/task/renderer.php @@ -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'); } diff --git a/admin/tool/task/tests/behat/manage_tasks.feature b/admin/tool/task/tests/behat/manage_tasks.feature index 160451d7340..dd27d85f713 100644 --- a/admin/tool/task/tests/behat/manage_tasks.feature +++ b/admin/tool/task/tests/behat/manage_tasks.feature @@ -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"