Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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 tiny_premium;
20
 
21
use advanced_testcase;
22
 
23
/**
24
 * Unit tests for the \tiny_premium\plugininfo class.
25
 *
26
 * @package     tiny_premium
27
 * @covers      \tiny_premium\plugininfo::get_plugin_configuration_for_external
28
 * @copyright   2025 Moodle Pty Ltd
29
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
final class plugininfo_test extends advanced_testcase {
32
 
33
    /**
34
     * Basic setup for tests.
35
     */
36
    public function setUp(): void {
37
        parent::setUp();
38
        $this->resetAfterTest(true);
39
 
40
        foreach (\tiny_premium\manager::get_plugins() as $plugin) {
41
            \tiny_premium\manager::set_plugin_config(['enabled' => 1], $plugin);
42
        }
43
    }
44
 
45
    /**
46
     * Test the get_plugin_configuration_for_external method.
47
     *
48
     * @return void
49
     */
50
    public function test_get_plugin_configuration_for_external(): void {
51
        global $CFG;
52
 
53
        $generator = $this->getDataGenerator();
54
        $user = $generator->create_user();
55
        $context = \context_system::instance();
56
        $this->setUser($user);
57
 
58
        $this->assertEquals(
59
            ['premiumplugins' => implode(',', \tiny_premium\manager::get_plugins())],
60
            plugininfo::get_plugin_configuration_for_external($context)
61
        );
62
    }
63
}