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