Passed
Pull Request — master (#30)
by Dmitriy
145:02 queued 129:54
created

ReaderFactoryTest::testCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 11
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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