|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Tests\Assets; |
| 4 | + |
| 5 | +use Illuminate\Foundation\Testing\RefreshDatabase; |
| 6 | +use Illuminate\Support\Facades\Storage; |
| 7 | +use Statamic\Facades; |
| 8 | +use Tests\TestCase; |
| 9 | + |
| 10 | +class AssetTest extends TestCase |
| 11 | +{ |
| 12 | + use RefreshDatabase; |
| 13 | + |
| 14 | + private $container; |
| 15 | + |
| 16 | + public function setUp(): void |
| 17 | + { |
| 18 | + parent::setUp(); |
| 19 | + |
| 20 | + Storage::fake('test', ['url' => '/assets']); |
| 21 | + |
| 22 | + $this->container = tap(Facades\AssetContainer::make('test')->disk('test'))->save(); |
| 23 | + |
| 24 | + Storage::disk('test')->put('a.jpg', ''); |
| 25 | + Facades\Asset::make()->container('test')->path('a.jpg')->save(); |
| 26 | + |
| 27 | + Storage::disk('test')->put('b.txt', ''); |
| 28 | + Facades\Asset::make()->container('test')->path('b.txt')->save(); |
| 29 | + |
| 30 | + Storage::disk('test')->put('c.txt', ''); |
| 31 | + Facades\Asset::make()->container('test')->path('c.txt')->save(); |
| 32 | + |
| 33 | + Storage::disk('test')->put('d.jpg', ''); |
| 34 | + Facades\Asset::make()->container('test')->path('d.jpg')->save(); |
| 35 | + |
| 36 | + Storage::disk('test')->put('e.jpg', ''); |
| 37 | + Facades\Asset::make()->container('test')->path('e.jpg')->save(); |
| 38 | + |
| 39 | + Storage::disk('test')->put('f.jpg', ''); |
| 40 | + Facades\Asset::make()->container('test')->path('f.jpg')->save(); |
| 41 | + } |
| 42 | + |
| 43 | + /** @test */ |
| 44 | + public function saving_an_asset_clears_the_eloquent_blink_cache() |
| 45 | + { |
| 46 | + $asset = Facades\Asset::find('test::f.jpg'); |
| 47 | + |
| 48 | + $this->assertTrue(Facades\Blink::has("eloquent-asset-{$asset->id()}")); |
| 49 | + |
| 50 | + $asset->save(); |
| 51 | + |
| 52 | + $this->assertFalse(Facades\Blink::has("eloquent-asset-{$asset->id()}")); |
| 53 | + } |
| 54 | +} |
0 commit comments