|
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
|
|
|
|