2626
2727class MappedAssetFactoryTest extends TestCase
2828{
29- private const DEFAULT_FIXTURES = __DIR__ .'/../Fixtures/assets/vendor ' ;
29+ private const FIXTURES_DIR = __DIR__ .'/../Fixtures ' ;
30+ private const VENDOR_FIXTURES_DIR = self ::FIXTURES_DIR .'/assets/vendor ' ;
3031
3132 private AssetMapperInterface &MockObject $ assetMapper ;
3233
3334 public function testCreateMappedAsset ()
3435 {
3536 $ factory = $ this ->createFactory ();
3637
37- $ asset = $ factory ->createMappedAsset ('file2.js ' , __DIR__ . ' /../Fixtures /dir1/file2.js ' );
38+ $ asset = $ factory ->createMappedAsset ('file2.js ' , self :: FIXTURES_DIR . ' /dir1/file2.js ' );
3839 $ this ->assertSame ('file2.js ' , $ asset ->logicalPath );
3940 $ this ->assertMatchesRegularExpression ('/^\/final-assets\/file2-[a-zA-Z0-9]{7,128}\.js$/ ' , $ asset ->publicPath );
4041 $ this ->assertSame ('/final-assets/file2.js ' , $ asset ->publicPathWithoutDigest );
@@ -43,7 +44,7 @@ public function testCreateMappedAsset()
4344 public function testCreateMappedAssetRespectsPreDigestedPaths ()
4445 {
4546 $ assetMapper = $ this ->createFactory ();
46- $ asset = $ assetMapper ->createMappedAsset ('already-abcdefVWXYZ0123456789.digested.css ' , __DIR__ . ' /../Fixtures /dir2/already-abcdefVWXYZ0123456789.digested.css ' );
47+ $ asset = $ assetMapper ->createMappedAsset ('already-abcdefVWXYZ0123456789.digested.css ' , self :: FIXTURES_DIR . ' /dir2/already-abcdefVWXYZ0123456789.digested.css ' );
4748 $ this ->assertSame ('already-abcdefVWXYZ0123456789.digested.css ' , $ asset ->logicalPath );
4849 $ this ->assertSame ('/final-assets/already-abcdefVWXYZ0123456789.digested.css ' , $ asset ->publicPath );
4950 // for pre-digested files, the digest *is* part of the public path
@@ -67,18 +68,18 @@ public function compile(string $content, MappedAsset $asset, AssetMapperInterfac
6768 $ assetMapper = $ this ->createFactory ($ file1Compiler );
6869 $ expected = 'totally changed ' ;
6970
70- $ asset = $ assetMapper ->createMappedAsset ('file1.css ' , __DIR__ . ' /../Fixtures /dir1/file1.css ' );
71+ $ asset = $ assetMapper ->createMappedAsset ('file1.css ' , self :: FIXTURES_DIR . ' /dir1/file1.css ' );
7172 $ this ->assertSame ($ expected , $ asset ->content );
7273
7374 // verify internal caching doesn't cause issues
74- $ asset = $ assetMapper ->createMappedAsset ('file1.css ' , __DIR__ . ' /../Fixtures /dir1/file1.css ' );
75+ $ asset = $ assetMapper ->createMappedAsset ('file1.css ' , self :: FIXTURES_DIR . ' /dir1/file1.css ' );
7576 $ this ->assertSame ($ expected , $ asset ->content );
7677 }
7778
7879 public function testCreateMappedAssetWithContentThatDoesNotChange ()
7980 {
8081 $ assetMapper = $ this ->createFactory ();
81- $ asset = $ assetMapper ->createMappedAsset ('file1.css ' , __DIR__ . ' /../Fixtures /dir1/file1.css ' );
82+ $ asset = $ assetMapper ->createMappedAsset ('file1.css ' , self :: FIXTURES_DIR . ' /dir1/file1.css ' );
8283 // null content because the final content matches the file source
8384 $ this ->assertNull ($ asset ->content );
8485 }
@@ -89,7 +90,7 @@ public function testCreateMappedAssetWithContentErrorsOnCircularReferences()
8990
9091 $ this ->expectException (CircularAssetsException::class);
9192 $ this ->expectExceptionMessage ('Circular reference detected while creating asset for "circular1.css": "circular1.css -> circular2.css -> circular1.css". ' );
92- $ factory ->createMappedAsset ('circular1.css ' , __DIR__ . ' /../Fixtures /circular_dir/circular1.css ' );
93+ $ factory ->createMappedAsset ('circular1.css ' , self :: FIXTURES_DIR . ' /circular_dir/circular1.css ' );
9394 }
9495
9596 public function testCreateMappedAssetWithDigest ()
@@ -111,43 +112,43 @@ public function compile(string $content, MappedAsset $asset, AssetMapperInterfac
111112 };
112113
113114 $ factory = $ this ->createFactory ();
114- $ asset = $ factory ->createMappedAsset ('subdir/file6.js ' , __DIR__ . ' /../Fixtures /dir2/subdir/file6.js ' );
115+ $ asset = $ factory ->createMappedAsset ('subdir/file6.js ' , self :: FIXTURES_DIR . ' /dir2/subdir/file6.js ' );
115116 $ this ->assertSame ('7f983f4053a57f07551fed6099c0da4e ' , $ asset ->digest );
116117 $ this ->assertFalse ($ asset ->isPredigested );
117118
118119 // trigger the compiler, which will change file5.js
119120 // since file6.js imports file5.js, the digest for file6 should change,
120121 // because, internally, the file path in file6.js to file5.js will need to change
121122 $ factory = $ this ->createFactory ($ file6Compiler );
122- $ asset = $ factory ->createMappedAsset ('subdir/file6.js ' , __DIR__ . ' /../Fixtures /dir2/subdir/file6.js ' );
123+ $ asset = $ factory ->createMappedAsset ('subdir/file6.js ' , self :: FIXTURES_DIR . ' /dir2/subdir/file6.js ' );
123124 $ this ->assertSame ('7e4f24ebddd4ab2a3bcf0d89270b9f30 ' , $ asset ->digest );
124125 }
125126
126127 public function testCreateMappedAssetWithPredigested ()
127128 {
128129 $ assetMapper = $ this ->createFactory ();
129- $ asset = $ assetMapper ->createMappedAsset ('already-abcdefVWXYZ0123456789.digested.css ' , __DIR__ . ' /../Fixtures /dir2/already-abcdefVWXYZ0123456789.digested.css ' );
130+ $ asset = $ assetMapper ->createMappedAsset ('already-abcdefVWXYZ0123456789.digested.css ' , self :: FIXTURES_DIR . ' /dir2/already-abcdefVWXYZ0123456789.digested.css ' );
130131 $ this ->assertSame ('abcdefVWXYZ0123456789.digested ' , $ asset ->digest );
131132 $ this ->assertTrue ($ asset ->isPredigested );
132133 }
133134
134135 public function testCreateMappedAssetInVendor ()
135136 {
136137 $ assetMapper = $ this ->createFactory ();
137- $ asset = $ assetMapper ->createMappedAsset ('lodash.js ' , __DIR__ . ' /../Fixtures/assets/vendor /lodash/lodash.index.js ' );
138+ $ asset = $ assetMapper ->createMappedAsset ('lodash.js ' , self :: VENDOR_FIXTURES_DIR . ' /lodash/lodash.index.js ' );
138139 $ this ->assertSame ('lodash.js ' , $ asset ->logicalPath );
139140 $ this ->assertTrue ($ asset ->isVendor );
140141 }
141142
142143 public function testCreateMappedAssetInMissingVendor ()
143144 {
144145 $ assetMapper = $ this ->createFactory (null , '/this-path-does-not-exist/ ' );
145- $ asset = $ assetMapper ->createMappedAsset ('lodash.js ' , __DIR__ . ' /../Fixtures/assets/vendor /lodash/lodash.index.js ' );
146+ $ asset = $ assetMapper ->createMappedAsset ('lodash.js ' , self :: VENDOR_FIXTURES_DIR . ' /lodash/lodash.index.js ' );
146147 $ this ->assertSame ('lodash.js ' , $ asset ->logicalPath );
147148 $ this ->assertFalse ($ asset ->isVendor );
148149 }
149150
150- private function createFactory (?AssetCompilerInterface $ extraCompiler = null , ?string $ vendorDir = self ::DEFAULT_FIXTURES ): MappedAssetFactory
151+ private function createFactory (?AssetCompilerInterface $ extraCompiler = null , ?string $ vendorDir = self ::VENDOR_FIXTURES_DIR ): MappedAssetFactory
151152 {
152153 $ compilers = [
153154 new JavaScriptImportPathCompiler ($ this ->createMock (ImportMapConfigReader::class)),
0 commit comments