Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
declare(strict_types=1);
18
 
19
namespace editor_tiny\plugininfo;
20
 
21
use advanced_testcase;
22
 
23
/**
24
 * Unit tests for the editor_tiny\tiny plugininfo class.
25
 *
26
 * @package     editor_tiny
27
 * @covers      \editor_tiny\plugininfo\tiny
28
 * @copyright   2023 Andrew Lyons <andrew@nicols.co.uk>
29
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class tiny_test extends advanced_testcase {
32
    /**
33
     * Uninstall is allowed of TinyMCE plugins.
34
     *
35
     * @covers ::is_uninstall_allowed
36
     */
37
    public function test_is_uninstall_allowed(): void {
38
        $instance = new tiny();
39
        $this->assertTrue($instance->is_uninstall_allowed());
40
    }
41
 
42
    /**
43
     * Check the manage URL.
44
     *
45
     * @covers ::get_manage_url
46
     */
47
    public function test_get_manage_url(): void {
48
        $this->assertInstanceOf(\moodle_url::class, tiny::get_manage_url());
49
    }
50
 
51
    /**
52
     * Test the get_enabled_plugins method.
53
     *
54
     * @covers ::get_enabled_plugin
55
     */
56
    public function test_get_enabled_plugins(): void {
57
        $this->resetAfterTest();
58
 
59
        $plugins = tiny::get_enabled_plugins();
60
        $this->assertArrayHasKey('recordrtc', $plugins);
61
        $this->assertArrayHasKey('media', $plugins);
62
        $this->assertArrayHasKey('autosave', $plugins);
63
        $this->assertArrayHasKey('h5p', $plugins);
64
 
65
        // Disable a plugin.
66
        tiny::enable_plugin('h5p', 0);
67
 
68
        $plugins = tiny::get_enabled_plugins();
69
        $this->assertArrayHasKey('recordrtc', $plugins);
70
        $this->assertArrayHasKey('media', $plugins);
71
        $this->assertArrayHasKey('autosave', $plugins);
72
        $this->assertArrayNotHasKey('h5p', $plugins);
73
    }
74
 
75
    /**
76
     * Ensure that the base implementation is used for plugins not supporting ordering.
77
     */
78
    public function test_sorting_not_supported(): void {
79
        $this->assertFalse(tiny::plugintype_supports_ordering());
80
 
81
        $this->assertNull(tiny::get_sorted_plugins());
82
        $this->assertNull(tiny::get_sorted_plugins(true));
83
        $this->assertNull(tiny::get_sorted_plugins(false));
84
 
85
        $this->assertFalse(tiny::change_plugin_order('tiny_h5p', \core\plugininfo\base::MOVE_UP));
86
        $this->assertFalse(tiny::change_plugin_order('tiny_h5p', \core\plugininfo\base::MOVE_DOWN));
87
    }
88
}