Passed
Pull Request — master (#22)
by Dmitriy
28:42 queued 13:51
created

ReaderFactoryTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 22
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkGet() 0 7 1
A testCreate() 0 11 1
1
<?php
2
3
namespace Yiisoft\Composer\Config\Tests\Unit\Reader;
4
5
use Yiisoft\Composer\Config\Builder;
6
use Yiisoft\Composer\Config\Reader\EnvReader;
7
use Yiisoft\Composer\Config\Reader\JsonReader;
8
use Yiisoft\Composer\Config\Reader\PhpReader;
9
use Yiisoft\Composer\Config\Reader\ReaderFactory;
10
use Yiisoft\Composer\Config\Reader\YamlReader;
11
12
/**
13
 * ReaderFactoryTest.
14
 */
15
class ReaderFactoryTest extends \PHPUnit\Framework\TestCase
16
{
17
    public function testCreate(): void
18
    {
19
        $this->checkGet('.env', EnvReader::class);
20
        $this->checkGet('.json', JsonReader::class);
21
        $yml = $this->checkGet('.yml', YamlReader::class);
22
        $yaml = $this->checkGet('.yaml', YamlReader::class);
23
        $php = $this->checkGet('.php', PhpReader::class);
24
        $php2 = $this->checkGet('.php', PhpReader::class);
25
26
        $this->assertNotSame($php, $php2);
27
        $this->assertNotSame($yml, $yaml);
28
    }
29
30
    public function checkGet(string $name, string $class)
31
    {
32
        $builder = $this->createMock(Builder::class);
33
        $reader = ReaderFactory::get($builder, $name);
34
        $this->assertInstanceOf($class, $reader);
35
36
        return $reader;
37
    }
38
}
39