This commit is contained in:
Andrew Nicols 2023-09-05 11:52:36 +08:00
commit 77dc50a76a
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 58 additions and 47 deletions

View File

@ -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',
],
];

View File

@ -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',
],
];