From 75cae1dede6f9d898eac7092547d467ee98637b3 Mon Sep 17 00:00:00 2001 From: Safat Date: Thu, 5 Oct 2023 16:21:08 +1100 Subject: [PATCH] MDL-79586 communication: Restrict the use of non-configured providers --- communication/classes/api.php | 5 ++++- communication/tests/api_test.php | 23 ----------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/communication/classes/api.php b/communication/classes/api.php index 8973d22b4c3..f94153ea8e0 100644 --- a/communication/classes/api.php +++ b/communication/classes/api.php @@ -166,7 +166,10 @@ class api { $selection[processor::PROVIDER_NONE] = get_string('nocommunicationselected', 'communication'); $communicationplugins = \core\plugininfo\communication::get_enabled_plugins(); foreach ($communicationplugins as $pluginname => $notusing) { - $selection['communication_' . $pluginname] = get_string('pluginname', 'communication_' . $pluginname); + $provider = 'communication_' . $pluginname; + if (processor::is_provider_available($provider)) { + $selection[$provider] = get_string('pluginname', 'communication_' . $pluginname); + } } return $selection; } diff --git a/communication/tests/api_test.php b/communication/tests/api_test.php index a0e92a6558d..484de5b311d 100644 --- a/communication/tests/api_test.php +++ b/communication/tests/api_test.php @@ -44,17 +44,6 @@ class api_test extends \advanced_testcase { $this->initialise_mock_server(); } - /** - * Test the communication plugin list for the form element returns the correct number of plugins. - */ - public function test_get_communication_plugin_list_for_form(): void { - $communicationplugins = \core_communication\api::get_communication_plugin_list_for_form(); - // Get the communication plugins. - $plugins = \core_component::get_plugin_list('communication'); - // Check the number of plugins matches plus 1 as we have none in the selection. - $this->assertCount(count($plugins) + 1, $communicationplugins); - } - /** * Test set data to the instance. */ @@ -285,18 +274,6 @@ class api_test extends \advanced_testcase { $this->assertCount(1, $adhoctask); } - /** - * Test the enabled communication plugin list and default. - */ - public function test_get_enabled_providers_and_default(): void { - [$communicationproviders, $defaulprovider] = \core_communication\api::get_enabled_providers_and_default(); - // Get the communication plugins. - $plugins = \core_component::get_plugin_list('communication'); - // Check the number of plugins matches plus 1 as we have none in the selection. - $this->assertCount(count($plugins) + 1, $communicationproviders); - $this->assertEquals(processor::PROVIDER_NONE, $defaulprovider); - } - /** * Test the update of room membership with the change user role. *