ReaderFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

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
20
/**
21
 * ReaderFactoryTest.
22
 */
23
class ReaderFactoryTest extends \PHPUnit\Framework\TestCase
24
{
25
    protected $builder;
26
27
    public function testCreate()
28
    {
29
        $this->builder = new Builder();
30
31
        $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...
32
        $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...
33
        $yml    = $this->checkGet('.yml',   YamlReader::class);
34
        $yaml   = $this->checkGet('.yaml',  YamlReader::class);
35
        $php    = $this->checkGet('.php',   PhpReader::class);
36
        $php2   = $this->checkGet('.php',   PhpReader::class);
37
38
        $this->assertSame($php, $php2);
39
        $this->assertSame($yml, $yaml);
40
    }
41
42
    public function checkGet(string $name, string $class)
43
    {
44
        $reader = ReaderFactory::get($this->builder, $name);
45
        $this->assertInstanceOf($class, $reader);
46
        $this->assertSame($this->builder, $reader->getBuilder());
47
48
        return $reader;
49
    }
50
}
51