15
15
use Symfony \Component \AssetMapper \ImportMap \ImportMapConfigReader ;
16
16
use Symfony \Component \AssetMapper \ImportMap \ImportMapEntries ;
17
17
use Symfony \Component \AssetMapper \ImportMap \ImportMapEntry ;
18
+ use Symfony \Component \AssetMapper \ImportMap \ImportMapType ;
18
19
use Symfony \Component \AssetMapper \ImportMap \ImportMapVersionChecker ;
19
20
use Symfony \Component \AssetMapper \ImportMap \PackageVersionProblem ;
20
21
use Symfony \Component \AssetMapper \ImportMap \RemotePackageDownloader ;
@@ -73,7 +74,7 @@ public static function getCheckVersionsTests()
73
74
{
74
75
yield 'no dependencies ' => [
75
76
[
76
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
77
+ self :: createRemoteEntry ('foo ' , '1.0.0 ' ),
77
78
],
78
79
[
79
80
'foo ' => [],
@@ -84,8 +85,8 @@ public static function getCheckVersionsTests()
84
85
85
86
yield 'single with dependency but no problem ' => [
86
87
[
87
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
88
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
88
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
89
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
89
90
],
90
91
[
91
92
'foo ' => ['bar ' ],
@@ -104,8 +105,8 @@ public static function getCheckVersionsTests()
104
105
105
106
yield 'single with dependency with problem ' => [
106
107
[
107
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
108
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
108
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
109
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
109
110
],
110
111
[
111
112
'foo ' => ['bar ' ],
@@ -124,9 +125,31 @@ public static function getCheckVersionsTests()
124
125
],
125
126
];
126
127
128
+ yield 'single with dependency & different package specifier with problem ' => [
129
+ [
130
+ self ::createRemoteEntry ('foo ' , version: '1.0.0 ' , packageModuleSpecifier: 'foo_package ' ),
131
+ self ::createRemoteEntry ('bar ' , version: '1.5.0 ' , packageModuleSpecifier: 'bar_package ' ),
132
+ ],
133
+ [
134
+ 'foo ' => ['bar ' ],
135
+ 'bar ' => [],
136
+ ],
137
+ [
138
+ [
139
+ 'url ' => '/foo_package/1.0.0 ' ,
140
+ 'response ' => [
141
+ 'dependencies ' => ['bar_package ' => '^2.0.0 ' ],
142
+ ],
143
+ ],
144
+ ],
145
+ [
146
+ new PackageVersionProblem ('foo_package ' , 'bar_package ' , '^2.0.0 ' , '1.5.0 ' ),
147
+ ],
148
+ ];
149
+
127
150
yield 'single with missing dependency ' => [
128
151
[
129
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
152
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
130
153
],
131
154
[
132
155
'foo ' => ['bar ' ],
@@ -146,9 +169,9 @@ public static function getCheckVersionsTests()
146
169
147
170
yield 'multiple package and problems ' => [
148
171
[
149
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
150
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
151
- new ImportMapEntry ('baz ' , version: '2.0.0 ' ),
172
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
173
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
174
+ self :: createRemoteEntry ('baz ' , version: '2.0.0 ' ),
152
175
],
153
176
[
154
177
'foo ' => ['bar ' ],
@@ -177,8 +200,8 @@ public static function getCheckVersionsTests()
177
200
178
201
yield 'single with problem on peerDependency ' => [
179
202
[
180
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
181
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
203
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
204
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
182
205
],
183
206
[
184
207
'foo ' => ['bar ' ],
@@ -199,8 +222,8 @@ public static function getCheckVersionsTests()
199
222
200
223
yield 'single that imports something that is not required by the package ' => [
201
224
[
202
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
203
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
225
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
226
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
204
227
],
205
228
[
206
229
'foo ' => ['bar ' ],
@@ -221,8 +244,8 @@ public static function getCheckVersionsTests()
221
244
222
245
yield 'single with npm-style constraint ' => [
223
246
[
224
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
225
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
247
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
248
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
226
249
],
227
250
[
228
251
'foo ' => ['bar ' ],
@@ -241,8 +264,8 @@ public static function getCheckVersionsTests()
241
264
242
265
yield 'single with invalid constraint shows as problem ' => [
243
266
[
244
- new ImportMapEntry ('foo ' , version: '1.0.0 ' ),
245
- new ImportMapEntry ('bar ' , version: '1.5.0 ' ),
267
+ self :: createRemoteEntry ('foo ' , version: '1.0.0 ' ),
268
+ self :: createRemoteEntry ('bar ' , version: '1.5.0 ' ),
246
269
],
247
270
[
248
271
'foo ' => ['bar ' ],
@@ -403,4 +426,10 @@ public static function getNpmSpecificVersionConstraints()
403
426
'~1 ' ,
404
427
];
405
428
}
429
+
430
+ private static function createRemoteEntry (string $ importName , string $ version , string $ packageModuleSpecifier = null ): ImportMapEntry
431
+ {
432
+ $ packageModuleSpecifier = $ packageModuleSpecifier ?? $ importName ;
433
+ return ImportMapEntry::createRemote ($ importName , ImportMapType::JS , '/path/to/ ' .$ importName , $ version , $ packageModuleSpecifier , false );
434
+ }
406
435
}
0 commit comments