ReaderFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 13 1
A checkGet() 0 7 1
1
<?php
2
/**
3
 * Composer plugin for config assembling
4
 *
5
 * @link      https://github.com/hiqdev/composer-config-plugin
6
 * @package   composer-config-plugin
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\composer\config\tests\unit\configs;
12
13
use hiqdev\composer\config\Builder;
14
use hiqdev\composer\config\readers\EnvReader;
15
use hiqdev\composer\config\readers\JsonReader;
16
use hiqdev\composer\config\readers\PhpReader;
17
use hiqdev\composer\config\readers\ReaderFactory;
18
use hiqdev\composer\config\readers\YamlReader;
19
use hiqdev\composer\config\tests\unit\TestCase;
20
21
/**
22
 * ReaderFactoryTest.
23
 */
24
class ReaderFactoryTest extends TestCase
25
{
26
    protected $builder;
27
28
    public function testCreate()
29
    {
30
        $this->builder = new Builder();
31
32
        $env    = $this->checkGet('.env',   EnvReader::class);
0 ignored issues
show
Unused Code introduced by
The assignment to $env is dead and can be removed.
Loading history...
33
        $json   = $this->checkGet('.json',  JsonReader::class);
0 ignored issues
show
Unused Code introduced by
The assignment to $json is dead and can be removed.
Loading history...
34
        $yml    = $this->checkGet('.yml',   YamlReader::class);
35
        $yaml   = $this->checkGet('.yaml',  YamlReader::class);
36
        $php    = $this->checkGet('.php',   PhpReader::class);
37
        $php2   = $this->checkGet('.php',   PhpReader::class);
38
39
        $this->assertSame($php, $php2);
40
        $this->assertSame($yml, $yaml);
41
    }
42
43
    public function checkGet($name, $class)
44
    {
45
        $reader = ReaderFactory::get($this->builder, $name);
46
        $this->assertInstanceOf($class, $reader);
47
        $this->assertSame($this->builder, $reader->getBuilder());
48
49
        return $reader;
50
    }
51
}
52