File tree 2 files changed +13
-3
lines changed
src/Symfony/Component/AssetMapper 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,6 @@ private function isVendor(string $sourcePath): bool
128
128
$ sourcePath = realpath ($ sourcePath );
129
129
$ vendorDir = realpath ($ this ->vendorDir );
130
130
131
- return $ sourcePath && str_starts_with ($ sourcePath , $ vendorDir );
131
+ return $ sourcePath && $ vendorDir && str_starts_with ($ sourcePath , $ vendorDir );
132
132
}
133
133
}
Original file line number Diff line number Diff line change 26
26
27
27
class MappedAssetFactoryTest extends TestCase
28
28
{
29
+ private const DEFAULT_FIXTURES = __DIR__ .'/../Fixtures/assets/vendor ' ;
30
+
29
31
private AssetMapperInterface &MockObject $ assetMapper ;
30
32
31
33
public function testCreateMappedAsset ()
@@ -137,7 +139,15 @@ public function testCreateMappedAssetInVendor()
137
139
$ this ->assertTrue ($ asset ->isVendor );
138
140
}
139
141
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 (?AssetCompilerInterface $ extraCompiler = null , ?string $ vendorDir = self ::DEFAULT_FIXTURES ): MappedAssetFactory
141
151
{
142
152
$ compilers = [
143
153
new JavaScriptImportPathCompiler ($ this ->createMock (ImportMapConfigReader::class)),
@@ -162,7 +172,7 @@ private function createFactory(?AssetCompilerInterface $extraCompiler = null): M
162
172
$ factory = new MappedAssetFactory (
163
173
$ pathResolver ,
164
174
$ compiler ,
165
- __DIR__ . ' /../Fixtures/assets/vendor ' ,
175
+ $ vendorDir ,
166
176
);
167
177
168
178
// mock the AssetMapper to behave like normal: by calling back to the factory
You can’t perform that action at this time.
0 commit comments