ConfigFactoryTest::testFactory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Test\BaseConfigTest;
14
15
/**
16
 * Class ConfigFactoryTest
17
 *
18
 * @package Asm\Tests\Config
19
 * @author marc aschmann <[email protected]>
20
 */
21
class ConfigFactoryTest extends BaseConfigTest
22
{
23
24
    /**
25
     * @covers \Asm\Config\Config::factory
26
     */
27
    public function testFactory()
28
    {
29
        $config = Config::factory(
30
            [
31
                'file' => $this->getTestYaml(),
32
            ],
33
            'ConfigDefault'
34
        );
35
36
        $this->assertInstanceOf('Asm\Config\ConfigDefault', $config);
37
    }
38
39
    /**
40
     * @covers \Asm\Config\Config::factory
41
     */
42 View Code Duplication
    public function testFactoryWithoutFilecheck()
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...
43
    {
44
        $config = Config::factory(
45
            [
46
                'file' => $this->getTestYaml(),
47
                'filecheck' => false,
48
            ],
49
            'ConfigDefault'
50
        );
51
52
        $this->assertInstanceOf('Asm\Config\ConfigDefault', $config);
53
    }
54
55
    /**
56
     * @expectedException \ErrorException
57
     * @throws \ErrorException
58
     */
59
    public function testFactoryErrorException()
60
    {
61
        $config = Config::factory(
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
62
            [
63
                'file' => $this->getTestYaml(),
64
            ],
65
            'ConfigXXX'
66
        );
67
    }
68
69
    /**
70
     * @expectedException \InvalidArgumentException
71
     * @throws \InvalidArgumentException
72
     */
73
    public function testFactoryInvalidArgumentException()
74
    {
75
        $config = Config::factory(
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
76
            [],
77
            'ConfigDefault'
78
        );
79
    }
80
}
81