Passed
Push — master ( 14a42b...4e4f6b )
by Andrii
02:16
created

ReaderFactoryTest   A

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\ReaderFactory;
15
use hiqdev\composer\config\readers\EnvReader;
16
use hiqdev\composer\config\readers\JsonReader;
17
use hiqdev\composer\config\readers\PhpReader;
18
use hiqdev\composer\config\readers\YamlReader;
19
20
/**
21
 * ReaderFactoryTest.
22
 */
23
class ReaderFactoryTest extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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