|
6 | 6 | use Illuminate\Support\Collection; |
7 | 7 | use PHPUnit\Framework\Attributes\DataProvider; |
8 | 8 | use PHPUnit\Framework\Attributes\Test; |
| 9 | +use Statamic\Stache\NullLockStore; |
9 | 10 | use Statamic\Stache\Stache; |
10 | 11 | use Statamic\Stache\Stores\ChildStore; |
11 | 12 | use Statamic\Stache\Stores\CollectionsStore; |
12 | 13 | use Statamic\Stache\Stores\EntriesStore; |
| 14 | +use Symfony\Component\Lock\LockFactory; |
13 | 15 | use Tests\TestCase; |
14 | 16 |
|
15 | 17 | class StacheTest extends TestCase |
@@ -61,6 +63,29 @@ public function stores_can_be_registered() |
61 | 63 | }); |
62 | 64 | } |
63 | 65 |
|
| 66 | + #[Test] |
| 67 | + public function stores_can_be_excluded_from_warming_and_clearing() |
| 68 | + { |
| 69 | + $this->stache->sites(['en']); // store expects the stache to have site(s) |
| 70 | + $this->assertTrue($this->stache->stores()->isEmpty()); |
| 71 | + |
| 72 | + $mockStore = $this->mock(CollectionsStore::class, function ($mock) { |
| 73 | + $mock->shouldReceive('warm')->never(); |
| 74 | + $mock->shouldReceive('clear')->never(); |
| 75 | + $mock->shouldReceive('key')->andReturn('collections'); |
| 76 | + }); |
| 77 | + |
| 78 | + $this->stache->registerStore($mockStore); |
| 79 | + |
| 80 | + $return = $this->stache->exclude('collections'); |
| 81 | + |
| 82 | + $this->assertEquals($this->stache, $return); |
| 83 | + |
| 84 | + $this->stache->setLockFactory(new LockFactory(new NullLockStore())); |
| 85 | + $this->stache->warm(); |
| 86 | + $this->stache->clear(); |
| 87 | + } |
| 88 | + |
64 | 89 | #[Test] |
65 | 90 | public function multiple_stores_can_be_registered_at_once() |
66 | 91 | { |
|
0 commit comments