@@ -323,11 +323,16 @@ public function testSynchronizeAssetMapperNewPackage()
323
323
file_put_contents ($ this ->tempDir .'/importmap.php ' , '<?php return []; ' );
324
324
325
325
$ fileModulePath = $ this ->tempDir .'/vendor/symfony/new-package/assets/dist/loader.js ' ;
326
- $ this ->scriptExecutor ->expects ($ this ->exactly (2 ))
326
+ $ entrypointPath = $ this ->tempDir .'/vendor/symfony/new-package/assets/entry.js ' ;
327
+ $ secondEntrypointPath = $ this ->tempDir .'/vendor/symfony/new-package/assets/entry2.js ' ;
328
+
329
+ $ this ->scriptExecutor ->expects ($ this ->exactly (4 ))
327
330
->method ('execute ' )
328
331
->withConsecutive (
329
332
['symfony-cmd ' , 'importmap:require ' , ['@hotcake/foo@^1.9.0 ' ]],
330
- ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package ' , '--path= ' .$ fileModulePath ]]
333
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package ' , '--path= ' .$ fileModulePath ]],
334
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package/entry.js ' , '--path= ' .$ entrypointPath , '--entrypoint ' ]],
335
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package/entry2.js ' , '--path= ' .$ secondEntrypointPath , '--entrypoint ' ]],
331
336
);
332
337
333
338
$ this ->synchronizer ->synchronize ([
@@ -396,14 +401,19 @@ public function testSynchronizeAssetMapperUpgradesPackageIfNeeded()
396
401
'version ' => '1.8.0 ' ,
397
402
],
398
403
];
399
- file_put_contents ($ this ->tempDir .'/importmap.php ' , sprintf ('<?php return %s; ' , var_export ($ importMap , true )));
404
+ file_put_contents ($ this ->tempDir .'/importmap.php ' , \ sprintf ('<?php return %s; ' , var_export ($ importMap , true )));
400
405
401
406
$ fileModulePath = $ this ->tempDir .'/vendor/symfony/new-package/assets/dist/loader.js ' ;
402
- $ this ->scriptExecutor ->expects ($ this ->exactly (2 ))
407
+ $ entrypointPath = $ this ->tempDir .'/vendor/symfony/new-package/assets/entry.js ' ;
408
+ $ secondEntrypointPath = $ this ->tempDir .'/vendor/symfony/new-package/assets/entry2.js ' ;
409
+
410
+ $ this ->scriptExecutor ->expects ($ this ->exactly (4 ))
403
411
->method ('execute ' )
404
412
->withConsecutive (
405
413
['symfony-cmd ' , 'importmap:require ' , ['@hotcake/foo@^1.9.0 ' ]],
406
- ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package ' , '--path= ' .$ fileModulePath ]]
414
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package ' , '--path= ' .$ fileModulePath ]],
415
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package/entry.js ' , '--path= ' .$ entrypointPath , '--entrypoint ' ]],
416
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package/entry2.js ' , '--path= ' .$ secondEntrypointPath , '--entrypoint ' ]]
407
417
);
408
418
409
419
$ this ->synchronizer ->synchronize ([
@@ -421,14 +431,21 @@ public function testSynchronizeAssetMapperSkipsUpgradeIfAlreadySatisfied()
421
431
// constraint in package.json is ^1.9.0
422
432
'version ' => '1.9.1 ' ,
423
433
],
434
+ '@symfony/new-package/entry2.js ' => [
435
+ 'path ' => './vendor/symfony/new-package/assets/entry2.js ' ,
436
+ 'entrypoint ' => true ,
437
+ ],
424
438
];
425
- file_put_contents ($ this ->tempDir .'/importmap.php ' , sprintf ('<?php return %s; ' , var_export ($ importMap , true )));
439
+ file_put_contents ($ this ->tempDir .'/importmap.php ' , \ sprintf ('<?php return %s; ' , var_export ($ importMap , true )));
426
440
427
441
$ fileModulePath = $ this ->tempDir .'/vendor/symfony/new-package/assets/dist/loader.js ' ;
428
- $ this ->scriptExecutor ->expects ($ this ->once ())
442
+ $ entrypointPath = $ this ->tempDir .'/vendor/symfony/new-package/assets/entry.js ' ;
443
+
444
+ $ this ->scriptExecutor ->expects ($ this ->exactly (2 ))
429
445
->method ('execute ' )
430
446
->withConsecutive (
431
- ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package ' , '--path= ' .$ fileModulePath ]]
447
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package ' , '--path= ' .$ fileModulePath ]],
448
+ ['symfony-cmd ' , 'importmap:require ' , ['@symfony/new-package/entry.js ' , '--path= ' .$ entrypointPath , '--entrypoint ' ]],
432
449
);
433
450
434
451
$ this ->synchronizer ->synchronize ([
@@ -438,4 +455,19 @@ public function testSynchronizeAssetMapperSkipsUpgradeIfAlreadySatisfied()
438
455
],
439
456
]);
440
457
}
458
+
459
+ public function testExceptionWhenInvalidImportMapConstraint ()
460
+ {
461
+ file_put_contents ($ this ->tempDir .'/importmap.php ' , '<?php return []; ' );
462
+
463
+ $ this ->expectException (\InvalidArgumentException::class);
464
+ $ this ->expectExceptionMessage ('Invalid constraint config for key "@symfony/test": "true" given, array or string expected. ' );
465
+
466
+ $ this ->synchronizer ->synchronize ([
467
+ [
468
+ 'name ' => 'symfony/importmap-invalid-constraint-package ' ,
469
+ 'keywords ' => ['symfony-ux ' ],
470
+ ],
471
+ ]);
472
+ }
441
473
}
0 commit comments