Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use Laravel cache helper instead of custom implementation #514

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
12 changes: 12 additions & 0 deletions config/cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

return [
'default' => 'file',

'stores' => [
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
],
];
8 changes: 3 additions & 5 deletions src/Commands/HydeInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Hyde\Framework\Concerns\Commands\AsksToRebuildSite;
use Hyde\Framework\Hyde;
use Illuminate\Support\Facades\Cache;
use LaravelZero\Framework\Commands\Command;

/**
Expand Down Expand Up @@ -148,14 +149,11 @@ protected function updateSiteUrl(): void

protected function markInstalled(): void
{
if (! is_dir(Hyde::path('.cache/hyde'))) {
mkdir(Hyde::path('.cache/hyde'), recursive: true);
}
touch(Hyde::path('.cache/hyde/installed'));
Cache::forever('hyde.installed', true);
}

protected function isInstalled(): bool
{
return file_exists(Hyde::path('.cache/hyde/installed'));
return Cache::get('hyde.installed', false) === true;
}
}
17 changes: 0 additions & 17 deletions tests/Feature/Commands/HydeInstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Tests\Feature\Commands;

use Hyde\Framework\Commands\HydeInstallCommand;
use Hyde\Framework\Hyde;
use Illuminate\Support\Facades\File;
use Tests\TestCase;

/**
Expand Down Expand Up @@ -113,21 +111,6 @@ public function test_command_calls_publish_homepage_command()
->assertExitCode(0);
}

public function test_mark_installed_creates_cache_directory_if_it_doesnt_exist()
{
File::deleteDirectory(Hyde::path('.cache/hyde'));
$this->assertDirectoryDoesNotExist(Hyde::path('.cache/hyde'));
$mock = new class extends HydeInstallCommand
{
public function test()
{
$this->markInstalled();
}
};
$mock->test();
$this->assertDirectoryExists(Hyde::path('.cache/hyde'));
}

public function test_mark_installed_option_marks_site_as_installed()
{
$this->artisan('install --mark-installed')
Expand Down