ConfTest4getIni   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A test_getIni_Beforeparsed() 0 6 1
B test_getIni_NoArgs() 0 32 1
A test_getIni_WithOneArgs() 0 13 1
A test_getIni_WithTwoArgs() 0 9 1
1
<?php
2
/**
3
 * ConfTest4getIni
4
 *
5
 * Conf::getIni用テストケース
6
 *
7
 * @package           risoluto
8
 * @author            Risoluto Developers
9
 * @license           http://opensource.org/licenses/bsd-license.php new BSD license
10
 * @copyright     (C) 2008-2015 Risoluto Developers / All Rights Reserved.
11
 */
12
//------------------------------------------------------//
13
// 名前空間の定義
14
//------------------------------------------------------//
15
namespace Risoluto;
16
17
//------------------------------------------------------//
18
// テストクラス定義
19
//------------------------------------------------------//
20
class ConfTest4getIni extends \PHPUnit_Framework_TestCase
21
{
22
    //------------------------------------------------------//
23
    // テストメソッド定義
24
    //------------------------------------------------------//
25
    /**
26
     * setUp()
27
     *
28
     * テストに必要な準備を実施
29
     */
30
    protected function setUp()
31
    {
32
    }
33
34
    /**
35
     * test_getIni_Beforeparsed()
36
     *
37
     * 未パース時のgetIni()の挙動をテストする
38
     */
39
    public function test_getIni_Beforeparsed()
40
    {
41
        $instance = new Conf;
42
        $this->assertNull( $instance->getIni() );
43
        unset( $instance );
44
    }
45
46
    /**
47
     * test_getIni_NoArgs()
48
     *
49
     * パース後のgetIni()の挙動をテストする(引数なし)
50
     */
51
    public function test_getIni_NoArgs()
52
    {
53
        $want = [
54
            "SEQ" => [
55
                "default" => "RisolutoApps\\Pages\\View",
56
                "error" => "RisolutoApps\\Error",
57
                "servicestop" => "RisolutoApps\\ServiceStop"
58
            ],
59
            "LOGGING" => [
60
                "loglevel" => "warn"
61
            ],
62
            "SESSION" => [
63
                "timeout" => 86400
64
            ],
65
            "LIMITS" => [
66
                "max_loadavg" => 3
67
            ],
68
            "THEME" => [
69
                "outboards" => "vendor"
70
            ],
71
            "AUTH" => [
72
                "provider" => "Risoluto\\AuthDb",
73
                "users" => "risoluto_users",
74
                "groups" => "risoluto_groups"
75
            ],
76
        ];
77
78
        $instance = new Conf;
79
        $instance->parse( RISOLUTO_CONF . 'risoluto.ini' );
80
        $this->assertEquals( $instance->getIni(), $want );
81
        unset( $instance );
82
    }
83
84
    /**
85
     * test_getIni_WithOneArgs()
86
     *
87
     * パース後のgetIni()の挙動をテストする(セクションのみ指定)
88
     */
89
    public function test_getIni_WithOneArgs()
90
    {
91
        $want = [
92
            "default" => "RisolutoApps\\Pages\\View",
93
            "error" => "RisolutoApps\\Error",
94
            "servicestop" => "RisolutoApps\\ServiceStop"
95
        ];
96
97
        $instance = new Conf;
98
        $instance->parse( RISOLUTO_CONF . 'risoluto.ini' );
99
        $this->assertEquals( $instance->getIni( 'SEQ' ), $want );
100
        unset( $instance );
101
    }
102
103
    /**
104
     * test_getIni_WithTwoArgs()
105
     *
106
     * パース後のgetIni()の挙動をテストする(セクションのみ指定)
107
     */
108
    public function test_getIni_WithTwoArgs()
109
    {
110
        $want = "RisolutoApps\\Pages\\View";
111
112
        $instance = new Conf;
113
        $instance->parse( RISOLUTO_CONF . 'risoluto.ini' );
114
        $this->assertEquals( $instance->getIni( 'SEQ', 'default' ), $want );
115
        unset( $instance );
116
    }
117
}
118