ConfigEnvTest::testConfigMerge()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the php-utilities package.
4
 *
5
 * (c) Marc Aschmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Asm\Tests\Config;
11
12
use Asm\Config\Config;
13
use Asm\Config\ConfigEnv;
14
use Asm\Test\BaseConfigTest;
15
use Asm\Test\TestData;
16
17
/**
18
 * Class ConfigEnvTest
19
 *
20
 * @package Asm\Tests\Config
21
 * @author marc aschmann <[email protected]>
22
 */
23
class ConfigEnvTest extends BaseConfigTest
24
{
25
    /**
26
     * @covers \Asm\Config\ConfigEnv::mergeEnvironments
27
     * @covers \Asm\Config\ConfigEnv::__construct
28
     * @return \Asm\Config\ConfigInterface
29
     */
30 View Code Duplication
    public function testFactoryProd()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        // merged environments config
33
        $config = Config::factory(
34
            [
35
                'file' => $this->getTestYaml(),
36
            ],
37
            'ConfigEnv'
38
        );
39
40
        $this->assertInstanceOf('Asm\Config\ConfigEnv', $config);
41
42
        return $config;
43
    }
44
45
    /**
46
     * @covers \Asm\Config\ConfigEnv::mergeEnvironments
47
     * @covers \Asm\Config\ConfigEnv::__construct
48
     * @return \Asm\Config\ConfigInterface
49
     */
50
    public function testFactoryProdWithoutFilecheck()
51
    {
52
        // merged environments config
53
        $config = Config::factory(
54
            [
55
                'file' => TestData::getYamlConfigFile(),
56
                'filecheck' => false,
57
            ],
58
            'ConfigEnv'
59
        );
60
61
        $this->assertInstanceOf('Asm\Config\ConfigEnv', $config);
62
63
        return $config;
64
    }
65
66
    /**
67
     * @covers \Asm\Config\ConfigEnv::mergeEnvironments
68
     * @covers \Asm\Config\ConfigEnv::__construct
69
     * @return \Asm\Config\ConfigInterface
70
     */
71
    public function testFactoryEnv()
72
    {
73
        $config = Config::factory(
74
            [
75
                'file' => $this->getTestYaml(),
76
                'defaultEnv' => 'prod',
77
                'env' => 'dev',
78
            ],
79
            'ConfigEnv'
80
        );
81
82
        $this->assertInstanceOf('Asm\Config\ConfigEnv', $config);
83
84
        return $config;
85
    }
86
87
    /**
88
     * @depends testFactoryEnv
89
     * @param ConfigEnv $config
90
     */
91
    public function testConfigMerge(ConfigEnv $config)
92
    {
93
        $this->assertEquals(25, $config->get('testkey_2', 0));
94
    }
95
96
97
    /**
98
     * @depends testFactoryEnv
99
     * @param ConfigEnv $config
100
     */
101
    public function testConfigInclude(ConfigEnv $config)
102
    {
103
        $this->assertEquals(
104
            [
105
                'default' => 'yaddayadda',
106
                'my_test' => 'is testing hard'
107
            ],
108
            $config->get('testkey_5')
109
        );
110
    }
111
112
    /**
113
     * @depends testFactoryEnv
114
     * @param ConfigEnv $config
115
     */
116
    public function testConfigDefaultNode(ConfigEnv $config)
117
    {
118
        $this->assertEquals(
119
            'default test',
120
            $config->get('testkey_4')
121
        );
122
    }
123
}
124