From 4bfba20caa9f784540ed089bf4ec41e43072b8ae Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 12 Apr 2024 16:30:49 +0100 Subject: [PATCH 1/4] Fix typo to ensure files are actually removed from the disk --- src/Testing/AddonTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Testing/AddonTestCase.php b/src/Testing/AddonTestCase.php index f62f6643d69..1ff5ef6020f 100644 --- a/src/Testing/AddonTestCase.php +++ b/src/Testing/AddonTestCase.php @@ -43,7 +43,7 @@ public function tearDown(): void { $uses = array_flip(class_uses_recursive(static::class)); - if (isset($uses[PreventSavingStacheItemsToDisk::class])) { + if (isset($uses[PreventsSavingStacheItemsToDisk::class])) { $this->deleteFakeStacheDirectory(); } From 730461710df1a2690e7f65f4cf5d1ddb69de48bd Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 12 Apr 2024 16:32:52 +0100 Subject: [PATCH 2/4] Configure default Stache directories in `AddonTestCase` --- src/Testing/AddonTestCase.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Testing/AddonTestCase.php b/src/Testing/AddonTestCase.php index 1ff5ef6020f..cedebd4f7e2 100644 --- a/src/Testing/AddonTestCase.php +++ b/src/Testing/AddonTestCase.php @@ -8,6 +8,7 @@ use ReflectionClass; use Statamic\Console\Processes\Composer; use Statamic\Extend\Manifest; +use Statamic\Facades\Path; use Statamic\Providers\StatamicServiceProvider; use Statamic\Statamic; use Statamic\Testing\Concerns\PreventsSavingStacheItemsToDisk; @@ -97,5 +98,19 @@ protected function getEnvironmentSetUp($app) ]; $app['config']->set('statamic.users.repository', 'file'); + + $app['config']->set('statamic.stache.watcher', false); + $app['config']->set('statamic.stache.stores.taxonomies.directory', $directory.'/../tests/__fixtures__/content/taxonomies'); + $app['config']->set('statamic.stache.stores.terms.directory', $directory.'/../tests/__fixtures__/content/taxonomies'); + $app['config']->set('statamic.stache.stores.collections.directory', $directory.'/../tests/__fixtures__/content/collections'); + $app['config']->set('statamic.stache.stores.entries.directory', $directory.'/../tests/__fixtures__/content/collections'); + $app['config']->set('statamic.stache.stores.navigation.directory', $directory.'/../tests/__fixtures__/content/navigation'); + $app['config']->set('statamic.stache.stores.globals.directory', $directory.'/../tests/__fixtures__/content/globals'); + $app['config']->set('statamic.stache.stores.global-variables.directory', $directory.'/../tests/__fixtures__/content/globals'); + $app['config']->set('statamic.stache.stores.asset-containers.directory', $directory.'/../tests/__fixtures__/content/assets'); + $app['config']->set('statamic.stache.stores.nav-trees.directory', $directory.'/../tests/__fixtures__/content/structures/navigation'); + $app['config']->set('statamic.stache.stores.collection-trees.directory', $directory.'/../tests/__fixtures__/content/structures/collections'); + $app['config']->set('statamic.stache.stores.form-submissions.directory', $directory.'/../tests/__fixtures__/content/submissions'); + $app['config']->set('statamic.stache.stores.users.directory', $directory.'/../tests/__fixtures__/users'); } } From 73dea60695bd891dfa436994607e3532e59e8dc1 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 12 Apr 2024 16:33:12 +0100 Subject: [PATCH 3/4] Fix path issues --- src/Testing/Concerns/PreventsSavingStacheItemsToDisk.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Testing/Concerns/PreventsSavingStacheItemsToDisk.php b/src/Testing/Concerns/PreventsSavingStacheItemsToDisk.php index 0e921140c6f..af572acbbfc 100644 --- a/src/Testing/Concerns/PreventsSavingStacheItemsToDisk.php +++ b/src/Testing/Concerns/PreventsSavingStacheItemsToDisk.php @@ -13,8 +13,11 @@ protected function preventSavingStacheItemsToDisk(): void $this->fakeStacheDirectory = Path::tidy($this->fakeStacheDirectory); Stache::stores()->each(function ($store) { - $dir = Path::tidy(Str::before($this->fakeStacheDirectory, '/dev-null')); - $relative = Str::after(Str::after($store->directory(), $dir), '/'); + $fixturesPath = Str::before($this->fakeStacheDirectory, '/dev-null'); + $storeDirectory = '/'.Path::makeRelative($store->directory()); + + $relative = Str::after(Str::after($storeDirectory, $fixturesPath), '/'); + $store->directory($this->fakeStacheDirectory.'/'.$relative); }); } From 0c02529bfaeedd283b00bc4b85a8010ced034a33 Mon Sep 17 00:00:00 2001 From: duncanmcclean Date: Fri, 12 Apr 2024 15:34:50 +0000 Subject: [PATCH 4/4] Fix styling --- src/Testing/AddonTestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Testing/AddonTestCase.php b/src/Testing/AddonTestCase.php index cedebd4f7e2..edbaf6cd475 100644 --- a/src/Testing/AddonTestCase.php +++ b/src/Testing/AddonTestCase.php @@ -8,7 +8,6 @@ use ReflectionClass; use Statamic\Console\Processes\Composer; use Statamic\Extend\Manifest; -use Statamic\Facades\Path; use Statamic\Providers\StatamicServiceProvider; use Statamic\Statamic; use Statamic\Testing\Concerns\PreventsSavingStacheItemsToDisk;