xref: /dokuwiki/_test/tests/conf/CascadeProtectedTest.php (revision ec34bb300b254ecd0dba0fac22d8115635141cc5)
1<?php
2
3class CascadeProtectedTest extends DokuWikiTest
4{
5
6    public function setUp(): void
7    {
8        global $config_cascade;
9
10        $this->pluginsEnabled = [
11            'testing'
12        ];
13
14        $out = "<?php\n/*\n * protected settings, cannot modified in the Config manager\n" .
15            " * Some test data */\n";
16        $out .= "\$conf['title'] = 'Protected Title';\n";
17        $out .= "\$conf['tagline'] = 'Protected Tagline';\n";
18        $out .= "\$conf['plugin']['testing']['schnibble'] = 1;\n";
19        $out .= "\$conf['plugin']['testing']['second'] = 'Protected setting';\n";
20
21        file_put_contents(end($config_cascade['main']['protected']), $out);
22
23        parent::setUp();
24    }
25
26    public function testDefaults()
27    {
28        global $conf;
29
30        $this->assertEquals('Protected Title', $conf['title'], 'protected local value, overrides local');
31        $this->assertEquals('Protected Tagline', $conf['tagline'], 'protected local value, override default');
32
33        $testing = plugin_load('action', 'testing');
34        $this->assertEquals(1, $testing->getConf('schnibble'), 'protected local value, ');
35        $this->assertEquals('Protected setting', $testing->getConf('second'), 'protected local value');
36    }
37
38    public function tearDown(): void
39    {
40        global $config_cascade;
41
42        unlink(end($config_cascade['main']['protected']));
43
44        parent::tearDown();
45    }
46}
47