@@ -58,7 +58,7 @@ public function testCompileFindsCorrectImports(string $input, array $expectedJav
58
58
->method ('getAsset ' )
59
59
->willReturnCallback (function ($ path ) {
60
60
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 ' ),
62
62
default => null ,
63
63
};
64
64
});
@@ -67,11 +67,11 @@ public function testCompileFindsCorrectImports(string $input, array $expectedJav
67
67
->method ('getAssetFromSourcePath ' )
68
68
->willReturnCallback (function ($ path ) {
69
69
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 ' ),
75
75
default => null ,
76
76
};
77
77
});
@@ -81,7 +81,7 @@ public function testCompileFindsCorrectImports(string $input, array $expectedJav
81
81
$ this ->assertSame ($ input , $ compiler ->compile ($ input , $ asset , $ assetMapper ));
82
82
$ actualImports = [];
83
83
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 ];
85
85
}
86
86
87
87
$ this ->assertEquals ($ expectedJavaScriptImports , $ actualImports );
@@ -304,9 +304,9 @@ public function testCompileFindsRelativePathsViaSourcePath()
304
304
->method ('getAssetFromSourcePath ' )
305
305
->willRe
341A
turnCallback (function ($ path ) {
306
306
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 ' ),
310
310
default => throw new \RuntimeException (sprintf ('Unexpected source path "%s" ' , $ path )),
311
311
};
312
312
});
@@ -320,9 +320,9 @@ public function testCompileFindsRelativePathsViaSourcePath()
320
320
$ compiler = new JavaScriptImportPathCompiler ($ this ->createMock (ImportMapConfigReader::class));
321
321
$ compiler ->compile ($ input , $ inputAsset , $ assetMapper );
322
322
$ 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 );
326
326
}
327
327
328
328
public function testCompileFindsRelativePathsWithWindowsPathsViaSourcePath ()
@@ -337,9 +337,9 @@ public function testCompileFindsRelativePathsWithWindowsPathsViaSourcePath()
337
337
->method ('getAssetFromSourcePath ' )
338
338
->willReturnCallback (function ($ path ) {
339
339
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 ' ),
343
343
default => throw new \RuntimeException (sprintf ('Unexpected source path "%s" ' , $ path )),
344
344
};
345
345
});
@@ -366,7 +366,7 @@ public function testImportPathsCanUpdateForDifferentPublicPath(string $input, st
366
366
$ asset = new MappedAsset ('app.js ' , '/path/to/assets/app.js ' , publicPathWithoutDigest: $ inputAssetPublicPath );
367
367
368
368
$ assetMapper = $ this ->createMock (AssetMapperInterface::class);
369
- $ importedAsset = new MappedAsset ('anything ' , publicPathWithoutDigest: $ importedPublicPath );
369
+ $ importedAsset = new MappedAsset ('anything ' , ' /can/be/anything.js ' , publicPathWithoutDigest: $ importedPublicPath );
370
370
$ assetMapper ->expects ($ this ->once ())
371
371
->method ('getAssetFromSourcePath ' )
372
372
->willReturn ($ importedAsset );
@@ -436,7 +436,7 @@ public function testCompileHandlesCircularRelativeAssets()
436
436
$ input = 'import "./other.js"; ' ;
437
437
$ compiler ->compile ($ input , $ appAsset , $ assetMapper );
438
438
$ this ->assertCount (1 , $ appAsset ->getJavaScriptImports ());
439
- $ this ->assertSame ($ otherAsset , $ appAsset ->getJavaScriptImports ()[0 ]->asset );
439
+ $ this ->assertSame ($ otherAsset-> logicalPath , $ appAsset ->getJavaScriptImports ()[0 ]->assetLogicalPath );
440
440
}
441
441
442
442
public function testCompileHandlesCircularBareImportAssets ()
@@ -464,7 +464,7 @@ public function testCompileHandlesCircularBareImportAssets()
464
464
$ input = 'import "@popperjs/core"; ' ;
465
465
$ compiler ->compile ($ input , $ bootstrapAsset , $ assetMapper );
466
466
$ this ->assertCount (1 , $ bootstrapAsset ->getJavaScriptImports ());
467
- $ this ->assertSame ($ popperAsset , $ bootstrapAsset ->getJavaScriptImports ()[0 ]->asset );
467
+ $ this ->assertSame ($ popperAsset-> logicalPath , $ bootstrapAsset ->getJavaScriptImports ()[0 ]->assetLogicalPath );
468
468
}
469
469
470
470
/**
@@ -490,7 +490,7 @@ public function testMissingImportMode(string $sourceLogicalName, string $input,
490
490
->method ('getAssetFromSourcePath ' )
491
491
->willReturnCallback (function ($ sourcePath ) {
492
492
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 ' ),
494
494
default => null ,
495
495
};
496
496
}
0 commit comments