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

AssetsBuilderTest::testAssetBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\Discovery\Tests;
5
6
use Composer\Installer\InstallationManager;
7
use Composer\IO\BufferIO;
8
use Composer\Package\Package;
9
use Composer\Repository\RepositoryInterface;
10
use TheCodingMachine\Discovery\AssetsBuilder;
11
12
class AssetsBuilderTest extends AbstractDiscoveryTest
13
{
14
    public function testAssetBuilder()
15
    {
16
        $installationManager = $this->getInstallationManagerMock();
17
18
        $packageA = new Package('package/a', '1.0.0', '1.0.0');
19
20
        $io = new BufferIO();
21
22
        $assetsBuilder = new AssetsBuilder($installationManager, $io, '.');
23
        $assetTypes = $assetsBuilder->buildAssetTypes([ $packageA ]);
24
25
        $this->assertCount(1, $assetTypes);
26
        $this->assertArrayHasKey('test-asset', $assetTypes);
27
        $this->assertEmpty($io->getOutput());
28
    }
29
30
    public function testAssetBuilderErrorHandling()
31
    {
32
        $installationManager = $this->getInstallationManagerMock('tests/fixtures/package_error');
33
34
        $packageA = new Package('package/a', '1.0.0', '1.0.0');
35
36
        $io = new BufferIO();
37
38
        $assetsBuilder = new AssetsBuilder($installationManager, $io, '.');
39
        $assetTypes = $assetsBuilder->buildAssetTypes([ $packageA ]);
40
41
        $this->assertCount(0, $assetTypes);
42
        $this->assertNotEmpty($io->getOutput());
43
    }
44
45
    public function testFindAssetTypes()
46
    {
47
48
        $installationManager = $this->getInstallationManagerMock();
49
50
51
        $io = new BufferIO();
52
53
        $assetsBuilder = new AssetsBuilder($installationManager, $io, '.');
54
55
        $repository = $this->getRepositoryMock();
56
57
        $assetTypes = $assetsBuilder->findAssetTypes($repository);
58
59
        $this->assertCount(1, $assetTypes);
60
    }
61
}
62