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