MDL-79586 communication: Restrict the use of non-configured providers

This commit is contained in:
Safat
2023-10-05 16:53:50 +11:00
parent 73f342233a
commit 75cae1dede
2 changed files with 4 additions and 24 deletions
+4 -1
View File
@@ -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;
}
-23
View File
@@ -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.
*