-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
Asset::clearCaches
protected (#308)
* Add asset blink test * Bump core requirement
- Loading branch information
1 parent
4155c76
commit d05dea9
Showing
3 changed files
with
56 additions
and
2 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,54 @@ | ||
<?php | ||
|
||
namespace Tests\Assets; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Facades\Storage; | ||
use Statamic\Facades; | ||
use Tests\TestCase; | ||
|
||
class AssetTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
private $container; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Storage::fake('test', ['url' => '/assets']); | ||
|
||
$this->container = tap(Facades\AssetContainer::make('test')->disk('test'))->save(); | ||
|
||
Storage::disk('test')->put('a.jpg', ''); | ||
Facades\Asset::make()->container('test')->path('a.jpg')->save(); | ||
|
||
Storage::disk('test')->put('b.txt', ''); | ||
Facades\Asset::make()->container('test')->path('b.txt')->save(); | ||
|
||
Storage::disk('test')->put('c.txt', ''); | ||
Facades\Asset::make()->container('test')->path('c.txt')->save(); | ||
|
||
Storage::disk('test')->put('d.jpg', ''); | ||
Facades\Asset::make()->container('test')->path('d.jpg')->save(); | ||
|
||
Storage::disk('test')->put('e.jpg', ''); | ||
Facades\Asset::make()->container('test')->path('e.jpg')->save(); | ||
|
||
Storage::disk('test')->put('f.jpg', ''); | ||
Facades\Asset::make()->container('test')->path('f.jpg')->save(); | ||
} | ||
|
||
/** @test */ | ||
public function saving_an_asset_clears_the_eloquent_blink_cache() | ||
{ | ||
$asset = Facades\Asset::find('test::f.jpg'); | ||
|
||
$this->assertTrue(Facades\Blink::has("eloquent-asset-{$asset->id()}")); | ||
|
||
$asset->save(); | ||
|
||
$this->assertFalse(Facades\Blink::has("eloquent-asset-{$asset->id()}")); | ||
} | ||
} |