2626
2727class MappedAssetFactoryTest extends TestCase
2828{
29+ private const DEFAULT_FIXTURES = __DIR__ .'/../Fixtures/assets/vendor ' ;
30+
2931 private AssetMapperInterface &MockObject $ assetMapper ;
3032
3133 public function testCreateMappedAsset ()
@@ -137,7 +139,18 @@ public function testCreateMappedAssetInVendor()
137139 $ this ->assertTrue ($ asset ->isVendor );
138140 }
139141
140- private function createFactory (?AssetCompilerInterface $ extraCompiler = null ): MappedAssetFactory
142+ public function testCreateMappedAssetInMissingVendor ()
143+ {
144+ $ assetMapper = $ this ->createFactory (null , '/this-path-does-not-exist/ ' );
145+ $ asset = $ assetMapper ->createMappedAsset ('lodash.js ' , __DIR__ .'/../Fixtures/assets/vendor/lodash/lodash.index.js ' );
146+ $ this ->assertSame ('lodash.js ' , $ asset ->logicalPath );
147+ $ this ->assertFalse ($ asset ->isVendor );
148+ }
149+
150+ private function createFactory (
151+ ?AssetCompilerInterface $ extraCompiler = null ,
152+ ?string $ vendorDir = self ::DEFAULT_FIXTURES ,
153+ ): MappedAssetFactory
141154 {
142155 $ compilers = [
143156 new JavaScriptImportPathCompiler ($ this ->createMock (ImportMapConfigReader::class)),
@@ -162,7 +175,7 @@ private function createFactory(?AssetCompilerInterface $extraCompiler = null): M
162175 $ factory = new MappedAssetFactory (
163176 $ pathResolver ,
164177 $ compiler ,
165- __DIR__ . ' /../Fixtures/assets/vendor ' ,
178+ $ vendorDir ,
166179 );
167180
168181 // mock the AssetMapper to behave like normal: by calling back to the factory
0 commit comments