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\media
27
 * @covers      \core\plugininfo\media
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 media_test extends advanced_testcase {
31
final class media_test extends advanced_testcase {
Línea 32... Línea 32...
32
 
32
 
33
    /**
33
    /**
34
     * Test the get_enabled_plugins method.
-
 
35
     *
-
 
36
     * @covers ::get_enabled_plugins
34
     * Test the get_enabled_plugins method.
37
     */
35
     */
38
    public function test_get_enabled_plugins(): void {
36
    public function test_get_enabled_plugins(): void {
Línea 39... Línea 37...
39
        $this->resetAfterTest();
37
        $this->resetAfterTest();
Línea 67... Línea 65...
67
    /**
65
    /**
68
     * Data provider for the is_uninstall_allowed tests.
66
     * Data provider for the is_uninstall_allowed tests.
69
     *
67
     *
70
     * @return array
68
     * @return array
71
     */
69
     */
72
    public function is_uninstall_allowed_provider(): array {
70
    public static function is_uninstall_allowed_provider(): array {
73
        $plugins = media::get_enabled_plugins();
71
        $plugins = media::get_enabled_plugins();
74
        return array_map(function ($plugin) {
72
        return array_map(function ($plugin) {
75
            return [
73
            return [
76
                'plugin' => $plugin,
74
                'plugin' => $plugin,
77
            ];
75
            ];
Línea 83... Línea 81...
83
     *
81
     *
84
     * @dataProvider change_plugin_order_provider
82
     * @dataProvider change_plugin_order_provider
85
     * @param string $initialorder
83
     * @param string $initialorder
86
     * @param string $pluginname
84
     * @param string $pluginname
87
     * @param int $direction
85
     * @param int $direction
88
     * @param array $neworder
86
     * @param array $expected
89
     */
87
     */
90
    public function test_change_plugin_order(
88
    public function test_change_plugin_order(
91
        array $initialorder,
89
        array $initialorder,
92
        string $pluginname,
90
        string $pluginname,
93
        int $direction,
91
        int $direction,
94
        array $neworder,
92
        array $expected,
95
    ): void {
93
    ): void {
96
        $this->resetAfterTest(true);
94
        $this->resetAfterTest(true);
Línea 97... Línea 95...
97
 
95
 
98
        media::set_enabled_plugins($initialorder);
96
        media::set_enabled_plugins($initialorder);
Línea 99... Línea 97...
99
        media::change_plugin_order($pluginname, $direction);
97
        media::change_plugin_order($pluginname, $direction);
100
 
98
 
101
        $this->assertSame(
99
        $this->assertSame(
102
            $neworder,
100
            $expected,
103
            array_keys(media::get_sorted_plugins()),
101
            array_keys(media::get_sorted_plugins()),
Línea 104... Línea 102...
104
        );
102
        );
105
    }
103
    }
106
 
104
 
107
    public function change_plugin_order_provider(): array {
105
    public static function change_plugin_order_provider(): array {
108
        $pluginmanager = \core_plugin_manager::instance();
106
        $pluginmanager = \core_plugin_manager::instance();
109
        $allplugins = $pluginmanager->get_plugins_of_type('media');
107
        $allplugins = $pluginmanager->get_plugins_of_type('media');