Total Complexity | 3 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait InteractsWithCache |
||
10 | { |
||
11 | /** |
||
12 | * Assert that the Laravel Octane cache has the given key set |
||
13 | * |
||
14 | * @param string $key |
||
15 | * @param mixed|null $value |
||
16 | * @return static |
||
17 | */ |
||
18 | 1 | public function assertOctaneCacheHas(string $key, mixed $value = null): static |
|
19 | { |
||
20 | 1 | $cache = $this->app->cache->store('octane'); |
|
21 | |||
22 | 1 | if ($value === null) { |
|
23 | 1 | $this->assertTrue($cache->has($key), "The Octane cache doesn't have the [$key] key set"); |
|
|
|||
24 | } else { |
||
25 | 1 | $actual = $cache->get($key); |
|
26 | 1 | $this->assertSame($value, $actual, "Expected cached value [$value], got [$actual] instead"); |
|
27 | } |
||
28 | |||
29 | 1 | return $this; |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Assert that the Laravel Octane cache doesn't have the given key set |
||
34 | * |
||
35 | * @param string $key |
||
36 | * @return static |
||
37 | */ |
||
38 | 1 | public function assertOctaneCacheMissing(string $key): static |
|
45 | } |
||
46 | } |
||
47 |