Passed
Push — master ( 8bad73...c5d158 )
by David
57s queued 11s
created

DiscoveryTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 16
c 2
b 0
f 0
dl 0
loc 49
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyAssetType() 0 5 1
A testLocalDiscoveryJsonDetection() 0 5 1
A testValues() 0 5 1
A testAssetType() 0 7 1
A testSingleton() 0 3 1
A testEmptyValues() 0 5 1
A setUp() 0 5 1
1
<?php
2
3
4
namespace TheCodingMachine\Discovery;
5
6
use PHPUnit\Framework\TestCase;
7
8
class DiscoveryTest extends TestCase
9
{
10
    public function setUp(): void
11
    {
12
        parent::setUp();
13
        // Let's load the autogenerated class for the unit tests.
14
        require_once __DIR__.'/../.discovery/Discovery.php';
15
    }
16
17
    public function testSingleton()
18
    {
19
        $this->assertSame(Discovery::getInstance(), Discovery::getInstance());
20
    }
21
22
    public function testValues()
23
    {
24
        $result = Discovery::getInstance()->get('test-asset');
25
26
        $this->assertSame([ 'a1', 'a2', 'b' ], $result);
27
    }
28
29
    public function testEmptyValues()
30
    {
31
        $result = Discovery::getInstance()->get('not-exist');
32
33
        $this->assertSame([], $result);
34
    }
35
36
    public function testAssetType()
37
    {
38
        $result = Discovery::getInstance()->getAssetType('test-asset');
39
40
        $this->assertSame('a1', $result->getAssets()[0]->getValue());
41
        $this->assertSame('package/a', $result->getAssets()[0]->getPackage());
42
        $this->assertSame('fixtures/package_a/', $result->getAssets()[0]->getPackageDir());
43
    }
44
45
    public function testEmptyAssetType()
46
    {
47
        $result = Discovery::getInstance()->getAssetType('not-exist');
48
49
        $this->assertSame([], $result->getAssets());
50
    }
51
52
    public function testLocalDiscoveryJsonDetection()
53
    {
54
        $result = Discovery::getInstance()->getAssetType('local');
55
56
        $this->assertSame('local', $result->getAssets()[0]->getValue());
57
    }
58
59
}
60