aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/config/_test/ConfigParserTest.php
blob: b7e33a53912b463ae0a6767a0cdf8cb0454b3d20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php

namespace dokuwiki\plugin\config\test;

use dokuwiki\plugin\config\core\ConfigParser;

/**
 * @group plugin_config
 * @group admin_plugins
 * @group plugins
 * @group bundled_plugins
 */
class ConfigParserTest extends \DokuWikiTest {

    function test_readconfig() {
        $parser = new ConfigParser();
        $conf = $parser->parse(__DIR__ . '/data/config.php');

        // var_dump($conf);

        $this->assertEquals('42', $conf['int1']);
        $this->assertEquals('6*7', $conf['int2']);

        $this->assertEquals('Hello World', $conf['str1']);
        $this->assertEquals('G\'day World', $conf['str2']);
        $this->assertEquals('Hello World', $conf['str3']);
        $this->assertEquals("Hello 'World'", $conf['str4']);
        $this->assertEquals('Hello "World"', $conf['str5']);

        $this->assertEquals(array('foo', 'bar', 'baz'), $conf['arr1']);
    }

    function test_readconfig_onoff() {
        $parser = new ConfigParser();
        $conf = $parser->parse(__DIR__ . '/data/config.php');

        // var_dump($conf);

        $this->assertEquals(0, $conf['onoff1']);
        $this->assertEquals(1, $conf['onoff2']);
        $this->assertEquals(2, $conf['onoff3']);
        $this->assertEquals(0, $conf['onoff4']);
        $this->assertEquals(1, $conf['onoff5']);
        $this->assertEquals(false, $conf['onoff6']);
        $this->assertEquals(true, $conf['onoff7']);
        $this->assertEquals('false', $conf['onoff8']);
        $this->assertEquals('true', $conf['onoff9']);

        $this->assertEquals('false senctence', $conf['str11']);
        $this->assertEquals('true sentence', $conf['str12']);
        $this->assertEquals('truesfdf', $conf['str13']);
        $this->assertEquals("true", $conf['str14']);
        $this->assertEquals("truesfdsf", $conf['str15']);

        $this->assertTrue($conf['onoff1'] == false);
        $this->assertTrue($conf['onoff2'] == true);
        $this->assertTrue($conf['onoff3'] == true);
        $this->assertTrue($conf['onoff4'] == false);
        $this->assertTrue($conf['onoff5'] == true);
        $this->assertTrue($conf['onoff6'] == false);
        $this->assertTrue($conf['onoff7'] == true);
        $this->assertTrue($conf['onoff8'] == true); //string
        $this->assertTrue($conf['onoff9'] == true); //string
    }

}