|
7 | 7 | use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
8 | 8 | use Illuminate\Filesystem\Filesystem;
|
9 | 9 | use Illuminate\Support\Carbon;
|
| 10 | +use Illuminate\Support\Str; |
10 | 11 | use Mockery as m;
|
11 | 12 | use PHPUnit\Framework\TestCase;
|
12 | 13 |
|
@@ -330,6 +331,49 @@ public function testFlushIgnoreNonExistingDirectory()
|
330 | 331 | $this->assertFalse($result, 'Flush should not clean directory');
|
331 | 332 | }
|
332 | 333 |
|
| 334 | + public function testItHandlesForgettingNonFlexibleKeys() |
| 335 | + { |
| 336 | + $store = new FileStore(new Filesystem, __DIR__); |
| 337 | + |
| 338 | + $key = Str::random(); |
| 339 | + $path = $store->path($key); |
| 340 | + $flexiblePath = "illuminate:cache:flexible:created:{$key}"; |
| 341 | + |
| 342 | + $store->put($key, 'value', 5); |
| 343 | + |
| 344 | + $this->assertFileExists($path); |
| 345 | + $this->assertFileDoesNotExist($flexiblePath); |
| 346 | + |
| 347 | + $store->forget($key); |
| 348 | + |
| 349 | + $this->assertFileDoesNotExist($path); |
| 350 | + $this->assertFileDoesNotExist($flexiblePath); |
| 351 | + } |
| 352 | + |
| 353 | + public function itOnlyForgetsFlexibleKeysIfParentIsForgotten() |
| 354 | + { |
| 355 | + $store = new FileStore(new Filesystem, __DIR__); |
| 356 | + |
| 357 | + $key = Str::random(); |
| 358 | + $path = $store->path($key); |
| 359 | + $flexiblePath = "illuminate:cache:flexible:created:{$key}"; |
| 360 | + |
| 361 | + touch($flexiblePath); |
| 362 | + |
| 363 | + $this->assertFileDoesNotExist($path); |
| 364 | + $this->assertFileExists($flexiblePath); |
| 365 | + |
| 366 | + $store->forget($key); |
| 367 | + |
| 368 | + $this->assertFileDoesNotExist($path); |
| 369 | + $this->assertFileExists($flexiblePath); |
| 370 | + |
| 371 | + $store->put($key, 'value', 5); |
| 372 | + |
| 373 | + $this->assertFileDoesNotExist($path); |
| 374 | + $this->assertFileDoesNotExist($flexiblePath); |
| 375 | + } |
| 376 | + |
333 | 377 | protected function mockFilesystem()
|
334 | 378 | {
|
335 | 379 | return $this->createMock(Filesystem::class);
|
|
0 commit comments