-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] Custom file cache store adjustments (#10362)
- Loading branch information
1 parent
fa108ea
commit 1252b7a
Showing
3 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Tests\Extensions; | ||
|
||
use Illuminate\Cache\ArrayStore; | ||
use Illuminate\Support\Facades\Cache; | ||
use Orchestra\Testbench\Attributes\DefineEnvironment; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Statamic\Extensions\FileStore; | ||
use Tests\TestCase; | ||
|
||
class FileStoreTest extends TestCase | ||
{ | ||
#[Test] | ||
#[DefineEnvironment('cache')] | ||
public function it_overrides_file_driven_stores() | ||
{ | ||
$alfa = Cache::store('alfa')->getStore(); | ||
$this->assertInstanceOf(FileStore::class, $alfa); | ||
$this->assertEquals(storage_path('framework/cache/alfa'), $alfa->getDirectory()); | ||
|
||
$bravo = Cache::store('bravo')->getStore(); | ||
$this->assertInstanceOf(FileStore::class, $bravo); | ||
$this->assertEquals(storage_path('framework/cache/bravo'), $bravo->getDirectory()); | ||
|
||
// Non-file stores shouldn't be modified. | ||
$charlie = Cache::store('charlie')->getStore(); | ||
$this->assertInstanceOf(ArrayStore::class, $charlie); | ||
} | ||
|
||
public function cache($app) | ||
{ | ||
$app['config']->set('cache.stores.alfa', [ | ||
'driver' => 'file', | ||
'path' => storage_path('framework/cache/alfa'), | ||
]); | ||
|
||
$app['config']->set('cache.stores.bravo', [ | ||
'driver' => 'file', | ||
'path' => storage_path('framework/cache/bravo'), | ||
]); | ||
|
||
$app['config']->set('cache.stores.charlie', [ | ||
'driver' => 'array', | ||
]); | ||
} | ||
} |