|
18 | 18 | class CompiledAssetMapperConfigReaderTest extends TestCase
|
19 | 19 | {
|
20 | 20 | private Filesystem $filesystem;
|
21 |
| - private static string $writableRoot = __DIR__.'/../fixtures/importmaps_for_writing'; |
| 21 | + private string $writableRoot; |
22 | 22 |
|
23 | 23 | protected function setUp(): void
|
24 | 24 | {
|
25 | 25 | $this->filesystem = new Filesystem();
|
| 26 | + $this->writableRoot = __DIR__.'/../fixtures/importmaps_for_writing'; |
26 | 27 | if (!file_exists(__DIR__.'/../fixtures/importmaps_for_writing')) {
|
27 |
| - $this->filesystem->mkdir(self::$writableRoot); |
| 28 | + $this->filesystem->mkdir($this->writableRoot); |
28 | 29 | }
|
| 30 | + // realpath to help path comparisons in the tests |
| 31 | + $this->writableRoot = realpath($this->writableRoot); |
29 | 32 | }
|
30 | 33 |
|
31 | 34 | protected function tearDown(): void
|
32 | 35 | {
|
33 |
| - $this->filesystem->remove(self::$writableRoot); |
| 36 | + $this->filesystem->remove($this->writableRoot); |
34 | 37 | }
|
35 | 38 |
|
36 | 39 | public function testConfigExists()
|
37 | 40 | {
|
38 |
| - $reader = new CompiledAssetMapperConfigReader(self::$writableRoot); |
| 41 | + $reader = new CompiledAssetMapperConfigReader($this->writableRoot); |
39 | 42 | $this->assertFalse($reader->configExists('foo.json'));
|
40 |
| - $this->filesystem->touch(self::$writableRoot.'/foo.json'); |
| 43 | + $this->filesystem->touch($this->writableRoot.'/foo.json'); |
41 | 44 | $this->assertTrue($reader->configExists('foo.json'));
|
42 | 45 | }
|
43 | 46 |
|
44 | 47 | public function testLoadConfig()
|
45 | 48 | {
|
46 |
| - $reader = new CompiledAssetMapperConfigReader(self::$writableRoot); |
47 |
| - $this->filesystem->dumpFile(self::$writableRoot.'/foo.json', '{"foo": "bar"}'); |
| 49 | + $reader = new CompiledAssetMapperConfigReader($this->writableRoot); |
| 50 | + $this->filesystem->dumpFile($this->writableRoot.'/foo.json', '{"foo": "bar"}'); |
48 | 51 | $this->assertEquals(['foo' => 'bar'], $reader->loadConfig('foo.json'));
|
49 | 52 | }
|
50 | 53 |
|
51 | 54 | public function testSaveConfig()
|
52 | 55 | {
|
53 |
| - $reader = new CompiledAssetMapperConfigReader(self::$writableRoot); |
54 |
| - $this->assertEquals(self::$writableRoot.'/foo.json', $reader->saveConfig('foo.json', ['foo' => 'bar'])); |
55 |
| - $this->assertEquals(['foo' => 'bar'], json_decode(file_get_contents(self::$writableRoot.'/foo.json'), true)); |
| 56 | + $reader = new CompiledAssetMapperConfigReader($this->writableRoot); |
| 57 | + $this->assertEquals($this->writableRoot.'/foo.json', $reader->saveConfig('foo.json', ['foo' => 'bar'])); |
| 58 | + $this->assertEquals(['foo' => 'bar'], json_decode(file_get_contents($this->writableRoot.'/foo.json'), true)); |
56 | 59 | }
|
57 | 60 |
|
58 | 61 | public function testRemoveConfig()
|
59 | 62 | {
|
60 |
| - $reader = new CompiledAssetMapperConfigReader(self::$writableRoot); |
61 |
| - $this->filesystem->touch(self::$writableRoot.'/foo.json'); |
| 63 | + $reader = new CompiledAssetMapperConfigReader($this->writableRoot); |
| 64 | + $this->filesystem->touch($this->writableRoot.'/foo.json'); |
62 | 65 | $this->assertTrue($reader->configExists('foo.json'));
|
63 | 66 | $reader->removeConfig('foo.json');
|
64 | 67 | $this->assertFalse($reader->configExists('foo.json'));
|
|
0 commit comments