Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Console/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
70 changes: 70 additions & 0 deletions tests/Console/Commands/InstallTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Tests\Console\Commands;

use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Console\Commands\Install;
use Tests\TestCase;

class InstallTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

$this->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'));
}
}
Loading