-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathPluginTest.php
More file actions
111 lines (94 loc) · 3.54 KB
/
PluginTest.php
File metadata and controls
111 lines (94 loc) · 3.54 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
namespace tests\Http\Discovery\Composer;
use Composer\Package\Link;
use Composer\Package\Package;
use Composer\Repository\InstalledArrayRepository;
use Composer\Semver\Constraint\Constraint;
use Http\Discovery\Composer\Plugin;
use PHPUnit\Framework\TestCase;
/**
* @group NothingInstalled
*/
class PluginTest extends TestCase
{
/**
* @dataProvider provideMissingRequires
*/
public function testMissingRequires(array $expected, InstalledArrayRepository $repo, array $rootRequires, array $rootDevRequires)
{
$plugin = new Plugin();
$this->assertSame($expected, $plugin->getMissingRequires($repo, [$rootRequires, $rootDevRequires], true));
}
public static function provideMissingRequires()
{
$link = new Link('source', 'target', new Constraint(Constraint::STR_OP_GE, '1'));
$repo = new InstalledArrayRepository([
'php-http/discovery' => new Package('php-http/discovery', '1.0.0.0', '1.0'),
]);
yield 'empty' => [[[], [], []], $repo, [], []];
$rootRequires = [
'php-http/discovery' => $link,
'php-http/async-client-implementation' => $link,
'psr/http-message-implementation' => $link,
];
$expected = [[
'psr/http-message-implementation' => [],
'php-http/async-client-implementation' => [
'symfony/http-client',
'guzzlehttp/promises',
'php-http/message-factory',
],
'psr/http-factory-implementation' => [
'nyholm/psr7',
],
], [], []];
yield 'async-httplug' => [$expected, $repo, $rootRequires, []];
$repo = new InstalledArrayRepository([
'php-http/discovery' => new Package('php-http/discovery', '1.0.0.0', '1.0'),
'nyholm/psr7' => new Package('nyholm/psr7', '1.0.0.0', '1.0'),
]);
$repo->setDevPackageNames(['nyholm/psr7']);
$rootRequires = [
'php-http/discovery' => $link,
'php-http/async-client-implementation' => $link,
];
$expected = [[
'php-http/async-client-implementation' => [
'symfony/http-client',
'guzzlehttp/promises',
'php-http/message-factory',
],
'psr/http-factory-implementation' => [
'nyholm/psr7',
],
], [], [
'psr/http-factory-implementation' => [
'nyholm/psr7',
],
]];
yield 'move-to-require' => [$expected, $repo, $rootRequires, []];
$package = new Package('symfony/symfony', '1.0.0.0', '1.0');
$package->setReplaces([
'symfony/http-client' => new Link('symfony/symfony', 'symfony/http-client', new Constraint(Constraint::STR_OP_GE, '1'))
]);
$repo = new InstalledArrayRepository([
'php-http/discovery' => new Package('php-http/discovery', '1.0.0.0', '1.0'),
'symfony/symfony' => $package,
]);
$rootRequires = [
'php-http/discovery' => $link,
'php-http/async-client-implementation' => $link,
'symfony/symfony' => $link,
];
$expected = [[
'php-http/async-client-implementation' => [
'guzzlehttp/promises',
'php-http/message-factory',
],
'psr/http-factory-implementation' => [
'nyholm/psr7',
],
], [], []];
yield 'replace' => [$expected, $repo, $rootRequires, []];
}
}