@@ -58,7 +58,7 @@ public function testCompileFindsCorrectImports(string $input, array $expectedJav
5858 ->method ('getAsset ' )
5959 ->willReturnCallback (function ($ path ) {
6060 return match ($ path ) {
61- 'module_in_importmap_local_asset.js ' => new MappedAsset ('module_in_importmap_local_asset.js ' , publicPathWithoutDigest: '/assets/module_in_importmap_local_asset.js ' ),
61+ 'module_in_importmap_local_asset.js ' => new MappedAsset ('module_in_importmap_local_asset.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/module_in_importmap_local_asset.js ' ),
6262 default => null ,
6363 };
6464 });
@@ -67,11 +67,11 @@ public function testCompileFindsCorrectImports(string $input, array $expectedJav
6767 ->method ('getAssetFromSourcePath ' )
6868 ->willReturnCallback (function ($ path ) {
6969 return match ($ path ) {
70- '/project/assets/other.js ' => new MappedAsset ('other.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
71- '/project/assets/subdir/foo.js ' => new MappedAsset ('subdir/foo.js ' , publicPathWithoutDigest: '/assets/subdir/foo.js ' ),
72- '/project/assets/styles.css ' => new MappedAsset ('styles.css ' , publicPathWithoutDigest: '/assets/styles.css ' ),
73- '/project/assets/vendor/module_in_importmap_remote.js ' => new MappedAsset ('module_in_importmap_remote.js ' , publicPathWithoutDigest: '/assets/module_in_importmap_remote.js ' ),
74- '/project/assets/vendor/@popperjs/core.js ' => new MappedAsset ('assets/vendor/@popperjs/core.js ' , publicPathWithoutDigest: '/assets/@popperjs/core.js ' ),
70+ '/project/assets/other.js ' => new MappedAsset ('other.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
71+ '/project/assets/subdir/foo.js ' => new MappedAsset ('subdir/foo.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/subdir/foo.js ' ),
72+ '/project/assets/styles.css ' => new MappedAsset ('styles.css ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/styles.css ' ),
73+ '/project/assets/vendor/module_in_importmap_remote.js ' => new MappedAsset ('module_in_importmap_remote.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/module_in_importmap_remote.js ' ),
74+ '/project/assets/vendor/@popperjs/core.js ' => new MappedAsset ('assets/vendor/@popperjs/core.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/@popperjs/core.js ' ),
7575 default => null ,
7676 };
7777 });
@@ -81,7 +81,7 @@ public function testCompileFindsCorrectImports(string $input, array $expectedJav
8181 $ this ->assertSame ($ input , $ compiler ->compile ($ input , $ asset , $ assetMapper ));
8282 $ actualImports = [];
8383 foreach ($ asset ->getJavaScriptImports () as $ import ) {
84- $ actualImports [$ import ->importName ] = ['lazy ' => $ import ->isLazy , 'asset ' => $ import ->asset -> logicalPath , 'add ' => $ import ->addImplicitlyToImportMap ];
84+ $ actualImports [$ import ->importName ] = ['lazy ' => $ import ->isLazy , 'asset ' => $ import ->assetLogicalPath , 'add ' => $ import ->addImplicitlyToImportMap ];
8585 }
8686
8787 $ this ->assertEquals ($ expectedJavaScriptImports , $ actualImports );
@@ -304,9 +304,9 @@ public function testCompileFindsRelativePathsViaSourcePath()
304304 ->method ('getAssetFromSourcePath ' )
305305 ->willReturnCallback (function ($ path ) {
306306 return match ($ path ) {
307- '/project/assets/other.js ' => new MappedAsset ('other.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
308- '/project/assets/subdir/foo.js ' => new MappedAsset ('subdir/foo.js ' , publicPathWithoutDigest: '/assets/subdir/foo.js ' ),
309- '/project/root_asset.js ' => new MappedAsset ('root_asset.js ' , publicPathWithoutDigest: '/assets/root_asset.js ' ),
307+ '/project/assets/other.js ' => new MappedAsset ('other.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
308+ '/project/assets/subdir/foo.js ' => new MappedAsset ('subdir/foo.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/subdir/foo.js ' ),
309+ '/project/root_asset.js ' => new MappedAsset ('root_asset.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/root_asset.js ' ),
310310 default => throw new \RuntimeException (sprintf ('Unexpected source path "%s" ' , $ path )),
311311 };
312312 });
@@ -320,9 +320,9 @@ public function testCompileFindsRelativePathsViaSourcePath()
320320 $ compiler = new JavaScriptImportPathCompiler ($ this ->createMock (ImportMapConfigReader::class));
321321 $ compiler ->compile ($ input , $ inputAsset , $ assetMapper );
322322 $ this ->assertCount (3 , $ inputAsset ->getJavaScriptImports ());
323- $ this ->assertSame ('other.js ' , $ inputAsset ->getJavaScriptImports ()[0 ]->asset -> logicalPath );
324- $ this ->assertSame ('subdir/foo.js ' , $ inputAsset ->getJavaScriptImports ()[1 ]->asset -> logicalPath );
325- $ this ->assertSame ('root_asset.js ' , $ inputAsset ->getJavaScriptImports ()[2 ]->asset -> logicalPath );
323+ $ this ->assertSame ('other.js ' , $ inputAsset ->getJavaScriptImports ()[0 ]->assetLogicalPath );
324+ $ this ->assertSame ('subdir/foo.js ' , $ inputAsset ->getJavaScriptImports ()[1 ]->assetLogicalPath );
325+ $ this ->assertSame ('root_asset.js ' , $ inputAsset ->getJavaScriptImports ()[2 ]->assetLogicalPath );
326326 }
327327
328328 public function testCompileFindsRelativePathsWithWindowsPathsViaSourcePath ()
@@ -337,9 +337,9 @@ public function testCompileFindsRelativePathsWithWindowsPathsViaSourcePath()
337337 ->method ('getAssetFromSourcePath ' )
338338 ->willReturnCallback (function ($ path ) {
339339 return match ($ path ) {
340- 'C://project/assets/other.js ' => new MappedAsset ('other.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
341- 'C://project/assets/subdir/foo.js ' => new MappedAsset ('subdir/foo.js ' , publicPathWithoutDigest: '/assets/subdir/foo.js ' ),
342- 'C://project/root_asset.js ' => new MappedAsset ('root_asset.js ' , publicPathWithoutDigest: '/assets/root_asset.js ' ),
340+ 'C://project/assets/other.js ' => new MappedAsset ('other.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
341+ 'C://project/assets/subdir/foo.js ' => new MappedAsset ('subdir/foo.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/subdir/foo.js ' ),
342+ 'C://project/root_asset.js ' => new MappedAsset ('root_asset.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/root_asset.js ' ),
343343 default => throw new \RuntimeException (sprintf ('Unexpected source path "%s" ' , $ path )),
344344 };
345345 });
@@ -366,7 +366,7 @@ public function testImportPathsCanUpdateForDifferentPublicPath(string $input, st
366366 $ asset = new MappedAsset ('app.js ' , '/path/to/assets/app.js ' , publicPathWithoutDigest: $ inputAssetPublicPath );
367367
368368 $ assetMapper = $ this ->createMock (AssetMapperInterface::class);
369- $ importedAsset = new MappedAsset ('anything ' , publicPathWithoutDigest: $ importedPublicPath );
369+ $ importedAsset = new MappedAsset ('anything ' , ' /can/be/anything.js ' , publicPathWithoutDigest: $ importedPublicPath );
370370 $ assetMapper ->expects ($ this ->once ())
371371 ->method ('getAssetFromSourcePath ' )
372372 ->willReturn ($ importedAsset );
@@ -436,7 +436,7 @@ public function testCompileHandlesCircularRelativeAssets()
436436 $ input = 'import "./other.js"; ' ;
437437 $ compiler ->compile ($ input , $ appAsset , $ assetMapper );
438438 $ this ->assertCount (1 , $ appAsset ->getJavaScriptImports ());
439- $ this ->assertSame ($ otherAsset , $ appAsset ->getJavaScriptImports ()[0 ]->asset );
439+ $ this ->assertSame ($ otherAsset-> logicalPath , $ appAsset ->getJavaScriptImports ()[0 ]->assetLogicalPath );
440440 }
441441
442442 public function testCompileHandlesCircularBareImportAssets ()
@@ -464,7 +464,7 @@ public function testCompileHandlesCircularBareImportAssets()
464464 $ input = 'import "@popperjs/core"; ' ;
465465 $ compiler ->compile ($ input , $ bootstrapAsset , $ assetMapper );
466466 $ this ->assertCount (1 , $ bootstrapAsset ->getJavaScriptImports ());
467- $ this ->assertSame ($ popperAsset , $ bootstrapAsset ->getJavaScriptImports ()[0 ]->asset );
467+ $ this ->assertSame ($ popperAsset-> logicalPath , $ bootstrapAsset ->getJavaScriptImports ()[0 ]->assetLogicalPath );
468468 }
469469
470470 /**
@@ -490,7 +490,7 @@ public function testMissingImportMode(string $sourceLogicalName, string $input,
490490 ->method ('getAssetFromSourcePath ' )
491491 ->willReturnCallback (function ($ sourcePath ) {
492492 return match ($ sourcePath ) {
493- '/path/to/other.js ' => new MappedAsset ('other.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
493+ '/path/to/other.js ' => new MappedAsset ('other.js ' , ' /can/be/anything.js ' , publicPathWithoutDigest: '/assets/other.js ' ),
494494 default => null ,
495495 };
496496 }
0 commit comments