diff --git a/admin/tests/external/set_plugin_order_test.php b/admin/tests/external/set_plugin_order_test.php index 2b0a5c90ba6..8673e3c4ae1 100644 --- a/admin/tests/external/set_plugin_order_test.php +++ b/admin/tests/external/set_plugin_order_test.php @@ -73,27 +73,35 @@ class set_plugin_order_test extends \externallib_advanced_testcase { * @return array */ public function execute_editor_provider(): array { + $pluginmanager = \core_plugin_manager::instance(); + $allplugins = array_keys($pluginmanager->get_plugins_of_type('editor')); + + // Disabled editors are listed alphabetically at the end. + $getorder = function (array $plugins) use ($allplugins) { + return array_merge( + $plugins, + array_diff($allplugins, array_values($plugins)), + ); + }; return [ [ 'initialstate' => 'textarea,tiny', 'pluginname' => 'editor_textarea', 'direction' => 1, // DOWN. - 'expected' => [ + 'expected' => $getorder([ 'tiny', 'textarea', - 'atto', - ], + ]), 'newtexteditors' => 'tiny,textarea', ], [ 'initialstate' => 'textarea,tiny', 'pluginname' => 'editor_textarea', 'direction' => -1, // UP. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], [ @@ -101,11 +109,10 @@ class set_plugin_order_test extends \externallib_advanced_testcase { 'pluginname' => 'editor_tiny', 'direction' => 1, // DOWN. // Tiny is already at the bottom of the list of enabled plugins. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], [ @@ -113,11 +120,10 @@ class set_plugin_order_test extends \externallib_advanced_testcase { 'pluginname' => 'editor_atto', 'direction' => 1, // DOWN. // Atto is not enabled. Disabled editors are listed lexically after enabled editors. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], ]; diff --git a/lib/tests/plugininfo/editor_test.php b/lib/tests/plugininfo/editor_test.php index f22209e7ade..685d0dea8b2 100644 --- a/lib/tests/plugininfo/editor_test.php +++ b/lib/tests/plugininfo/editor_test.php @@ -102,6 +102,16 @@ class editor_test extends advanced_testcase { * @return array */ public function get_sorted_plugins_provider(): array { + $pluginmanager = \core_plugin_manager::instance(); + $allplugins = array_keys($pluginmanager->get_plugins_of_type('editor')); + + // Disabled editors are listed alphabetically at the end. + $getorder = function (array $plugins) use ($allplugins) { + return array_merge( + $plugins, + array_diff($allplugins, array_values($plugins)), + ); + }; return [ [ 'texteditors' => 'textarea,tiny', @@ -135,24 +145,17 @@ class editor_test extends advanced_testcase { [ 'texteditors' => 'textarea,tiny', 'enabledonly' => false, - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - - // Disabled editors are listed alphabetically at the end. - 'atto', - ], + ]), ], [ 'texteditors' => 'tiny', 'enabledonly' => false, - 'expected' => [ + 'expected' => $getorder([ 'tiny', - - // Disabled editors are listed alphabetically at the end. - 'atto', - 'textarea', - ], + ]), ], ]; } @@ -193,16 +196,25 @@ class editor_test extends advanced_testcase { * @return array */ public function change_plugin_order_provider(): array { + $pluginmanager = \core_plugin_manager::instance(); + $allplugins = array_keys($pluginmanager->get_plugins_of_type('editor')); + + // Disabled editors are listed alphabetically at the end. + $getorder = function (array $plugins) use ($allplugins) { + return array_merge( + $plugins, + array_diff($allplugins, array_values($plugins)), + ); + }; return [ [ 'texteditors' => 'textarea,tiny', 'pluginname' => 'textarea', 'direction' => base::MOVE_DOWN, - 'expected' => [ + 'expected' => $getorder([ 'tiny', 'textarea', - 'atto', - ], + ]), 'newtexteditors' => 'tiny,textarea', ], [ @@ -210,11 +222,10 @@ class editor_test extends advanced_testcase { 'pluginname' => 'tiny', 'direction' => base::MOVE_DOWN, // Tiny is already at the bottom of the enabled plugins. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], [ @@ -222,22 +233,20 @@ class editor_test extends advanced_testcase { 'pluginname' => 'atto', 'direction' => base::MOVE_DOWN, // Atto is not enabled. No change expected. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], [ 'texteditors' => 'textarea,tiny', 'pluginname' => 'tiny', 'direction' => base::MOVE_UP, - 'expected' => [ + 'expected' => $getorder([ 'tiny', 'textarea', - 'atto', - ], + ]), 'newtexteditors' => 'tiny,textarea', ], [ @@ -245,11 +254,10 @@ class editor_test extends advanced_testcase { 'pluginname' => 'tiny', 'direction' => base::MOVE_UP, // Tiny is already at the top of the enabled plugins. - 'expected' => [ + 'expected' => $getorder([ 'tiny', 'textarea', - 'atto', - ], + ]), 'newtexteditors' => 'tiny,textarea', ], [ @@ -257,11 +265,10 @@ class editor_test extends advanced_testcase { 'pluginname' => 'atto', 'direction' => base::MOVE_UP, // Atto is not enabled. No change expected. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], [ @@ -269,11 +276,10 @@ class editor_test extends advanced_testcase { 'pluginname' => 'atto', 'direction' => base::MOVE_UP, // Atto is not enabled. No change expected. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], [ @@ -281,11 +287,10 @@ class editor_test extends advanced_testcase { 'pluginname' => 'fakeeditor', 'direction' => base::MOVE_UP, // The fakeeditor plugin does not exist. No change expected. - 'expected' => [ + 'expected' => $getorder([ 'textarea', 'tiny', - 'atto', - ], + ]), 'newtexteditors' => 'textarea,tiny', ], ];