@@ -268,7 +268,7 @@ public static function provideResolvePackagesTests(): iterable
268
268
/**
269
269
* @dataProvider provideDownloadPackagesTests
270
270
*/
271
- public function testDownloadPackages (array $ importMapEntries , array $ expectedRequests , array $ expectedContents )
271
+ public function testDownloadPackages (array $ importMapEntries , array $ expectedRequests , array $ expectedReturn , array $ expectedDependencies = [] )
272
272
{
273
273
$ responses = [];
274
274
foreach ($ expectedRequests as $ expectedRequest ) {
@@ -284,14 +284,13 @@ public function testDownloadPackages(array $importMapEntries, array $expectedReq
284
284
285
285
$ provider = new JsDelivrEsmResolver ($ httpClient );
286
286
$ actualReturn = $ provider ->downloadPackages ($ importMapEntries );
287
- $ this ->assertCount (\count ($ expectedContents ), $ actualReturn );
288
287
289
- $ actualContents = [];
290
- foreach ($ actualReturn as $ package => $ data ) {
291
- $ actualContents [$ package ] = trim ($ data ['content ' ]);
288
+ foreach ($ actualReturn as $ key => $ data ) {
289
+ $ actualReturn [$ key ]['content ' ] = trim ($ data ['content ' ]);
292
290
}
291
+ $ this ->assertCount (\count ($ expectedReturn ), $ actualReturn );
293
292
294
- $ this ->assertSame ($ expectedContents , $ actualContents );
293
+ $ this ->assertSame ($ expectedReturn , $ actualReturn );
295
294
$ this ->assertSame (\count ($ expectedRequests ), $ httpClient ->getRequestsCount ());
296
295
}
297
296
@@ -306,7 +305,7 @@ public static function provideDownloadPackagesTests()
306
305
],
307
306
],
308
307
[
309
- 'lodash ' => ' lodash contents ' ,
308
+ 'lodash ' => [ ' content ' => ' lodash contents ', ' dependencies ' => []] ,
310
309
],
311
310
];
312
311
@@ -319,7 +318,7 @@ public static function provideDownloadPackagesTests()
319
318
],
320
319
],
321
320
[
322
- 'lodash ' => ' chart.js contents ' ,
321
+ 'lodash ' => [ ' content ' => ' chart.js contents ', ' dependencies ' => []] ,
323
322
],
324
323
];
325
324
@@ -332,7 +331,7 @@ public static function provideDownloadPackagesTests()
332
331
],
333
332
],
334
333
[
335
- 'lodash ' => ' bootstrap.css contents ' ,
334
+ 'lodash ' => [ ' content ' => ' bootstrap.css contents ', ' dependencies ' => []] ,
336
335
],
337
336
];
338
337
@@ -357,9 +356,9 @@ public static function provideDownloadPackagesTests()
357
356
],
358
357
],
359
358
[
360
- 'lodash ' => ' lodash contents ' ,
361
- 'chart.js/auto ' => ' chart.js contents ' ,
362
- 'bootstrap/dist/bootstrap.css ' => ' bootstrap.css contents ' ,
359
+ 'lodash ' => [ ' content ' => ' lodash contents ', ' dependencies ' => []] ,
360
+ 'chart.js/auto ' => [ ' content ' => ' chart.js contents ', ' dependencies ' => []] ,
361
+ 'bootstrap/dist/bootstrap.css ' => [ ' content ' => ' bootstrap.css contents ', ' dependencies ' => []] ,
363
362
],
364
363
];
365
364
@@ -374,11 +373,14 @@ public static function provideDownloadPackagesTests()
374
373
],
375
374
],
376
375
[
377
- '@chart.js/auto ' => 'import{Color as t}from"@kurkle/color";function e(){}const i=(()= ' ,
376
+ '@chart.js/auto ' => [
377
+ 'content ' => 'import{Color as t}from"@kurkle/color";function e(){}const i=(()= ' ,
378
+ 'dependencies ' => ['@kurkle/color ' ]
379
+ ],
378
380
],
379
381
];
380
382
381
- yield 'js importmap is removed ' => [
383
+ yield 'js sourcemap is removed ' => [
382
384
[
383
385
'@chart.js/auto ' => new ImportMapEntry ('chart.js/auto ' , version: '1.2.3 ' ),
384
386
],
@@ -390,7 +392,10 @@ public static function provideDownloadPackagesTests()
390
392
],
391
393
],
392
394
[
393
- '@chart.js/auto ' => 'as Ticks,ta as TimeScale,ia as TimeSeriesScale,oo as Title,wo as Tooltip,Ci as _adapters,us as _detectPlatform,Ye as animator,Si as controllers,tn as default,St as defaults,Pn as elements,qi as layouts,ko as plugins,na as registerables,Ps as registry,sa as scales}; ' ,
395
+ '@chart.js/auto ' => [
396
+ 'content ' => 'as Ticks,ta as TimeScale,ia as TimeSeriesScale,oo as Title,wo as Tooltip,Ci as _adapters,us as _detectPlatform,Ye as animator,Si as controllers,tn as default,St as defaults,Pn as elements,qi as layouts,ko as plugins,na as registerables,Ps as registry,sa as scales}; ' ,
397
+ 'dependencies ' => [],
398
+ ],
394
399
],
395
400
];
396
401
@@ -404,7 +409,10 @@ public static function provideDownloadPackagesTests()
404
409
],
405
410
],
406
411
[
407
- 'lodash ' => 'print-table-row{display:table-row!important}.d-print-table-cell{display:table-cell!important}.d-print-flex{display:flex!important}.d-print-inline-flex{display:inline-flex!important}.d-print-none{display:none!important}} ' ,
412
+ 'lodash ' => [
413
+ 'content ' => 'print-table-row{display:table-row!important}.d-print-table-cell{display:table-cell!important}.d-print-flex{display:flex!important}.d-print-inline-flex{display:inline-flex!important}.d-print-none{display:none!important}} ' ,
414
+ 'dependencies ' => [],
415
+ ],
408
416
],
409
417
];
410
418
}
0 commit comments