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

plugin_config_configuration_test   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 68
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A test_readconfig() 0 18 1
B test_readconfig_onoff() 0 33 1
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