Passed
Push — test ( d838cf...cef4a5 )
by Tom
03:29
created

PackageYamlFileReaderTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testReadingTestPackages() 0 5 1
A provideTestPackages() 0 6 1
A testReadingAndResolvingOfTestPackage() 0 10 1
A testReadingInexistentPackageFile() 0 7 1
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Runner\Docker\Binary;
6
7
use Ktomk\Pipelines\LibFsPath;
8
use Ktomk\Pipelines\TestCase;
9
10
/**
11
 * Class BinaryPackageYmlReaderTest
12
 *
13
 * @covers \Ktomk\Pipelines\Runner\Docker\Binary\PackageYamlFileReader
14
 */
15
class PackageYamlFileReaderTest extends TestCase
16
{
17
    public function testReadingAndResolvingOfTestPackage()
18
    {
19
        $testPackage = LibFsPath::normalizeSegments(
20
            __DIR__ . '/../../../../../lib/package/docker-42.42.1-binsh-test-stub.yml'
21
        );
22
23
        $reader = new PackageYamlFileReader($testPackage);
24
        $expected = UnpackagerTest::getTestPackage();
25
        $actual = $reader->asPackageArray();
26
        self::assertSame($expected, $actual);
27
    }
28
29
    /**
30
     *
31
     */
32
    public function provideTestPackages()
33
    {
34
        return array(
35
            array(__DIR__ . '/fixtures/no-uri.yml'),
36
            array(__DIR__ . '/fixtures/http-uri.yml'),
37
            array(__DIR__ . '/fixtures/absolute-path-uri.yml'),
38
        );
39
    }
40
41
    /**
42
     * @dataProvider provideTestPackages
43
     *
44
     * @param string $file
45
     */
46
    public function testReadingTestPackages($file)
47
    {
48
        $reader = new PackageYamlFileReader($file);
49
        $actual = $reader->asPackageArray();
50
        self::assertIsArray($actual);
51
    }
52
53
    public function testReadingInexistentPackageFile()
54
    {
55
        $file = '';
56
        $reader = new PackageYamlFileReader($file);
57
        $this->expectException('InvalidArgumentException');
58
        $this->expectExceptionMessage('not a readable file: ');
59
        $reader->asPackageArray();
60
    }
61
}
62