@@ -323,11 +323,16 @@ public function testSynchronizeAssetMapperNewPackage()
323323        file_put_contents ($ this tempDir .'/importmap.php ' , '<?php return []; ' );
324324
325325        $ 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 ))
327330            ->method ('execute ' )
328331            ->withConsecutive (
329332                ['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 ' ]],
331336            );
332337
333338        $ this synchronizer ->synchronize ([
@@ -396,14 +401,19 @@ public function testSynchronizeAssetMapperUpgradesPackageIfNeeded()
396401                'version '  => '1.8.0 ' ,
397402            ],
398403        ];
399-         file_put_contents ($ this tempDir .'/importmap.php ' , sprintf ('<?php return %s; ' , var_export ($ importMaptrue )));
404+         file_put_contents ($ this tempDir .'/importmap.php ' , \ sprintf'<?php return %s; ' , var_export ($ importMaptrue )));
400405
401406        $ 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 ))
403411            ->method ('execute ' )
404412            ->withConsecutive (
405413                ['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 ' ]]
407417            );
408418
409419        $ this synchronizer ->synchronize ([
@@ -421,14 +431,21 @@ public function testSynchronizeAssetMapperSkipsUpgradeIfAlreadySatisfied()
421431                // constraint in package.json is ^1.9.0 
422432                'version '  => '1.9.1 ' ,
423433            ],
434+             '@symfony/new-package/entry2.js '  => [
435+                 'path '  => './vendor/symfony/new-package/assets/entry2.js ' ,
436+                 'entrypoint '  => true ,
437+             ],
424438        ];
425-         file_put_contents ($ this tempDir .'/importmap.php ' , sprintf ('<?php return %s; ' , var_export ($ importMaptrue )));
439+         file_put_contents ($ this tempDir .'/importmap.php ' , \ sprintf'<?php return %s; ' , var_export ($ importMaptrue )));
426440
427441        $ 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 ))
429445            ->method ('execute ' )
430446            ->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 ' ]],
432449            );
433450
434451        $ this synchronizer ->synchronize ([
@@ -438,4 +455,19 @@ public function testSynchronizeAssetMapperSkipsUpgradeIfAlreadySatisfied()
438455            ],
439456        ]);
440457    }
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+     }
441473}
0 commit comments