-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathInstallerTest.php
97 lines (86 loc) · 3.06 KB
/
InstallerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Platformsh\Cli\Tests;
use Platformsh\Cli\Installer\Installer;
use Platformsh\Cli\Installer\VersionResolver;
class InstallerTest extends \PHPUnit_Framework_TestCase
{
public function setUp() {
require_once CLI_ROOT . '/dist/installer.php';
}
public function testFindInstallableVersionsChecksForSuffix()
{
$resolver = new VersionResolver();
$this->assertEquals(
[
['version' => '1.0.0'],
['version' => '1.0.1'],
['version' => '1.0.2-beta'],
],
$resolver->findInstallableVersions([
['version' => '1.0.0'],
['version' => '1.0.1'],
['version' => '1.0.2-beta'],
['version' => '1.0.3-dev'],
], PHP_VERSION, ['beta'])
);
$this->assertEquals(
[
['version' => '1.0.0-stable'],
['version' => '1.0.1'],
['version' => '1.0.2-beta'],
],
$resolver->findInstallableVersions([
['version' => '1.0.0-stable'],
['version' => '1.0.1'],
['version' => '1.0.2-beta'],
['version' => '1.0.3-dev'],
], PHP_VERSION, ['stable', 'beta'])
);
}
public function testFindInstallableVersionsChecksFoMinPhp()
{
$this->assertEmpty((new VersionResolver())->findInstallableVersions([
[
'version' => '1.0.0',
'php' => ['min' => '5.5.9'],
]
], '5.5.0'));
}
public function testFindLatestVersionWithMax()
{
$this->assertEquals('3.0.0', (new VersionResolver())->findLatestVersion([
['version' => '1.0.0'],
['version' => '2.0.0'],
['version' => '3.0.0'],
['version' => '3.0.1'],
], '', '3.0.0')['version']);
}
public function testFindLatestVersionWithMin()
{
$this->assertEquals('3.0.1', (new VersionResolver())->findLatestVersion([
['version' => '1.0.0'],
['version' => '3.0.1'],
['version' => '2.0.0'],
['version' => '3.0.0'],
], '2.0')['version']);
$this->setExpectedException(\RuntimeException::class);
(new VersionResolver())->findLatestVersion([
['version' => '1.0.0'],
['version' => '3.0.1'],
['version' => '2.0.0'],
['version' => '3.0.0'],
], 'v3.1');
}
public function testGetOption()
{
$method = new \ReflectionMethod(Installer::class, 'getOption');
$method->setAccessible(true);
$args = ['--min', '1.2.3'];
$this->assertEquals('1.2.3', $method->invoke(new Installer($args), 'min'));
$args = ['--max', '2.3.4'];
$this->assertEquals('', $method->invoke(new Installer($args), 'min'));
$this->assertEquals('2.3.4', $method->invoke(new Installer($args), 'max'));
$args = ['--max=2.0.0'];
$this->assertEquals('2.0.0', $method->invoke(new Installer($args), 'max'));
}
}