Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 26... Línea 26...
26
 * @package     core
26
 * @package     core
27
 * @covers      \core\plugininfo\editor
27
 * @covers      \core\plugininfo\editor
28
 * @copyright   2023 Andrew Lyons <andrew@nicols.co.uk>
28
 * @copyright   2023 Andrew Lyons <andrew@nicols.co.uk>
29
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
30
 */
31
class editor_test extends advanced_testcase {
31
final class editor_test extends advanced_testcase {
Línea 32... Línea 32...
32
 
32
 
33
    /**
33
    /**
34
     * Test that editor::get_enabled_plugins() returns the correct list of enabled plugins.
34
     * Test that editor::get_enabled_plugins() returns the correct list of enabled plugins.
35
     */
35
     */
Línea 99... Línea 99...
99
    /**
99
    /**
100
     * Data provider for the get_sorted_plugins tests.
100
     * Data provider for the get_sorted_plugins tests.
101
     *
101
     *
102
     * @return array
102
     * @return array
103
     */
103
     */
104
    public function get_sorted_plugins_provider(): array {
104
    public static function get_sorted_plugins_provider(): array {
105
        $pluginmanager = \core_plugin_manager::instance();
105
        $pluginmanager = \core_plugin_manager::instance();
106
        $allplugins = array_keys($pluginmanager->get_plugins_of_type('editor'));
106
        $allplugins = array_keys($pluginmanager->get_plugins_of_type('editor'));
Línea 107... Línea 107...
107
 
107
 
108
        // Disabled editors are listed alphabetically at the end.
108
        // Disabled editors are listed alphabetically at the end.
Línea 165... Línea 165...
165
     *
165
     *
166
     * @dataProvider change_plugin_order_provider
166
     * @dataProvider change_plugin_order_provider
167
     * @param string $texteditors
167
     * @param string $texteditors
168
     * @param string $pluginname
168
     * @param string $pluginname
169
     * @param int $direction
169
     * @param int $direction
170
     * @param array $neworder
170
     * @param array $expected
171
     * @param string $newtexteditors
171
     * @param string $newtexteditors
172
     */
172
     */
173
    public function test_change_plugin_order(
173
    public function test_change_plugin_order(
174
        string $texteditors,
174
        string $texteditors,
175
        string $pluginname,
175
        string $pluginname,
176
        int $direction,
176
        int $direction,
177
        array $neworder,
177
        array $expected,
178
        string $newtexteditors,
178
        string $newtexteditors,
179
    ): void {
179
    ): void {
180
        global $CFG;
180
        global $CFG;
181
        $this->resetAfterTest(true);
181
        $this->resetAfterTest(true);
Línea 182... Línea 182...
182
 
182
 
183
        $CFG->texteditors = $texteditors;
183
        $CFG->texteditors = $texteditors;
Línea 184... Línea 184...
184
        editor::change_plugin_order($pluginname, $direction);
184
        editor::change_plugin_order($pluginname, $direction);
185
 
185
 
186
        $this->assertSame(
186
        $this->assertSame(
187
            $neworder,
187
            $expected,
188
            array_keys(editor::get_sorted_plugins()),
188
            array_keys(editor::get_sorted_plugins()),
189
        );
189
        );
Línea 190... Línea 190...
190
        $this->assertSame($newtexteditors, $CFG->texteditors);
190
        $this->assertSame($newtexteditors, $CFG->texteditors);
191
    }
191
    }
192
 
192
 
193
    /**
193
    /**
194
     * Data provider fro the change_plugin_order() tests.
194
     * Data provider fro the change_plugin_order() tests.
195
     *
195
     *
196
     * @return array
196
     * @return array
197
     */
197
     */
Línea 198... Línea 198...
198
    public function change_plugin_order_provider(): array {
198
    public static function change_plugin_order_provider(): array {
199
        $pluginmanager = \core_plugin_manager::instance();
199
        $pluginmanager = \core_plugin_manager::instance();
Línea 230... Línea 230...
230
            ],
230
            ],
231
            [
231
            [
232
                'texteditors' => 'textarea,tiny',
232
                'texteditors' => 'textarea,tiny',
233
                'pluginname' => 'atto',
233
                'pluginname' => 'atto',
234
                'direction' => base::MOVE_DOWN,
234
                'direction' => base::MOVE_DOWN,
235
                // Atto is not enabled. No change expected.
235
                // Atto is not available. No change expected.
236
                'expected' => $getorder([
236
                'expected' => $getorder([
237
                    'textarea',
237
                    'textarea',
238
                    'tiny',
238
                    'tiny',
239
                ]),
239
                ]),
240
                'newtexteditors' => 'textarea,tiny',
240
                'newtexteditors' => 'textarea,tiny',
Línea 262... Línea 262...
262
            ],
262
            ],
263
            [
263
            [
264
                'texteditors' => 'textarea,tiny',
264
                'texteditors' => 'textarea,tiny',
265
                'pluginname' => 'atto',
265
                'pluginname' => 'atto',
266
                'direction' => base::MOVE_UP,
266
                'direction' => base::MOVE_UP,
267
                // Atto is not enabled. No change expected.
267
                // Atto is not available. No change expected.
268
                'expected' => $getorder([
-
 
269
                    'textarea',
-
 
270
                    'tiny',
-
 
271
                ]),
-
 
272
                'newtexteditors' => 'textarea,tiny',
-
 
273
            ],
-
 
274
            [
-
 
275
                'texteditors' => 'textarea,tiny',
-
 
276
                'pluginname' => 'atto',
-
 
277
                'direction' => base::MOVE_UP,
-
 
278
                // Atto is not enabled. No change expected.
-
 
279
                'expected' => $getorder([
268
                'expected' => $getorder([
280
                    'textarea',
269
                    'textarea',
281
                    'tiny',
270
                    'tiny',
282
                ]),
271
                ]),
283
                'newtexteditors' => 'textarea,tiny',
272
                'newtexteditors' => 'textarea,tiny',