ConfigTest::testLayeredConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
namespace Opine\Config;
3
4
use PHPUnit_Framework_TestCase;
5
use Opine\Config\Service as Config;
6
7
class ConfigTest extends PHPUnit_Framework_TestCase
8
{
9
    const ROOT = __DIR__.'/../public';
10
11
    public function testConfig()
12
    {
13
        $config = new Config(self::ROOT);
14
        $this->assertTrue($config->cacheSet());
15
        $config = $config->get('db');
16
        $this->assertTrue(is_array($config));
17
        $this->assertTrue('a' === $config['dsn']);
18
    }
19
20
    public function testLayeredConfig()
21
    {
22
        putenv('OPINE_ENV=dev');
23
        $config = new Config(self::ROOT);
24
        $this->assertTrue($config->cacheSet());
25
        $config = $config->get('db');
26
        $this->assertTrue(is_array($config));
27
        $this->assertTrue('q' === $config['dsn']);
28
    }
29
30
    public function testNestedGet() {
31
        $config = new Config(self::ROOT);
32
        $this->assertTrue($config->cacheSet());
33
        $dsn = $config->get('db.dsn');
34
        $this->assertTrue('q' === $dsn);
35
    }
36
}
37