mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
Merge branch 'MDL-79132' of https://github.com/AnupamaSarjoshi/moodle
This commit is contained in:
commit
77dc50a76a
30
admin/tests/external/set_plugin_order_test.php
vendored
30
admin/tests/external/set_plugin_order_test.php
vendored
@ -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',
|
||||
],
|
||||
];
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user