Completed
Push — onoffsetting ( 6388dc )
by Gerrit
04:37
created

plugin_config_configuration_test::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * @group plugin_config
4
 * @group admin_plugins
5
 * @group plugins
6
 * @group bundled_plugins
7
 */
8
9
class plugin_config_configuration_test extends DokuWikiTest {
10
11
    private $config = '';
12
    private $meta = '';
13
14
    /**
15
     * Load config files
16
     */
17
    function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
        $this->config = dirname(__FILE__).'/data/config.php';
19
        $this->meta   = dirname(__FILE__).'/data/metadata.php';
20
        require_once(dirname(__FILE__).'/../settings/config.class.php');
21
    }
22
23
    function test_readconfig() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
24
        $confmgr = new configuration($this->meta);
25
26
        $conf = $confmgr->_read_config($this->config);
27
28
        // var_dump($conf);
29
30
        $this->assertEquals('42', $conf['int1']);
31
        $this->assertEquals('6*7', $conf['int2']);
32
33
        $this->assertEquals('Hello World', $conf['str1']);
34
        $this->assertEquals('G\'day World', $conf['str2']);
35
        $this->assertEquals('Hello World', $conf['str3']);
36
        $this->assertEquals("Hello 'World'", $conf['str4']);
37
        $this->assertEquals('Hello "World"', $conf['str5']);
38
39
        $this->assertEquals(array('foo', 'bar', 'baz'), $conf['arr1']);
40
    }
41
42
    function test_readconfig_onoff() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
        $confmgr = new configuration($this->meta);
44
45
        $conf = $confmgr->_read_config($this->config);
46
47
        // var_dump($conf);
48
49
        $this->assertEquals(0, $conf['onoff1']);
50
        $this->assertEquals(1, $conf['onoff2']);
51
        $this->assertEquals(2, $conf['onoff3']);
52
        $this->assertEquals(0, $conf['onoff4']);
53
        $this->assertEquals(1, $conf['onoff5']);
54
        $this->assertEquals(false, $conf['onoff6']);
55
        $this->assertEquals(true, $conf['onoff7']);
56
        $this->assertEquals('false', $conf['onoff8']);
57
        $this->assertEquals('true', $conf['onoff9']);
58
59
        $this->assertEquals('false senctence', $conf['str11']);
60
        $this->assertEquals('true sentence', $conf['str12']);
61
        $this->assertEquals('truesfdf', $conf['str13']);
62
        $this->assertEquals("true", $conf['str14']);
63
        $this->assertEquals("truesfdsf", $conf['str15']);
64
65
        $this->assertTrue($conf['onoff1'] == false);
66
        $this->assertTrue($conf['onoff2'] == true);
67
        $this->assertTrue($conf['onoff3'] == true);
68
        $this->assertTrue($conf['onoff4'] == false);
69
        $this->assertTrue($conf['onoff5'] == true);
70
        $this->assertTrue($conf['onoff6'] == false);
71
        $this->assertTrue($conf['onoff7'] == true);
72
        $this->assertTrue($conf['onoff8'] == true); //string
73
        $this->assertTrue($conf['onoff9'] == true); //string
74
    }
75
76
}
77