From 6c7db6a8cea25619723323b5a8123a909e5f77db Mon Sep 17 00:00:00 2001 From: edalzell Date: Fri, 16 Oct 2026 13:23:43 -0700 Subject: [PATCH] Add --no-cache-clear option to statamic:install --- src/Console/Commands/Install.php | 6 ++- tests/Console/Commands/InstallTest.php | 70 ++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tests/Console/Commands/InstallTest.php diff --git a/src/Console/Commands/Install.php b/src/Console/Commands/Install.php index 2bf7592c910..95ce184ab16 100644 --- a/src/Console/Commands/Install.php +++ b/src/Console/Commands/Install.php @@ -19,7 +19,7 @@ class Install extends Command * * @var string */ - protected $signature = 'statamic:install'; + protected $signature = 'statamic:install {--no-cache-clear : Skip clearing the application cache}'; /** * The console command description. @@ -115,7 +115,9 @@ protected function clearViews() protected function clearCache() { - $this->call('cache:clear'); + if (! $this->option('no-cache-clear')) { + $this->call('cache:clear'); + } return $this; } diff --git a/tests/Console/Commands/InstallTest.php b/tests/Console/Commands/InstallTest.php new file mode 100644 index 00000000000..af6b69a7b0b --- /dev/null +++ b/tests/Console/Commands/InstallTest.php @@ -0,0 +1,70 @@ +app[Kernel::class]->registerCommand(new class extends Install + { + protected function addons() + { + return $this; + } + + protected function createFiles() + { + return $this; + } + + protected function publish() + { + return $this; + } + + protected function runCallbacks() + { + return $this; + } + + protected function clearViews() + { + return $this; + } + + protected function runUpdateScripts() + { + return $this; + } + }); + } + + #[Test] + public function it_clears_the_cache() + { + Cache::put('foo', 'bar'); + + $this->artisan('statamic:install'); + + $this->assertNull(Cache::get('foo')); + } + + #[Test] + public function it_can_skip_clearing_the_cache() + { + Cache::put('foo', 'bar'); + + $this->artisan('statamic:install', ['--no-cache-clear' => true]); + + $this->assertEquals('bar', Cache::get('foo')); + } +}