You are here

public function PersistentFileSystemBackendTest::testDeleteAll in File Cache 8

Test Drupal\Core\Cache\CacheBackendInterface::deleteAll().

Overrides GenericCacheBackendUnitTestBase::testDeleteAll

File

tests/src/Kernel/PersistentFileSystemBackendTest.php, line 47

Class

PersistentFileSystemBackendTest
Tests the FileSystemBackend cache backend using the persistent option.

Namespace

Drupal\Tests\filecache\Kernel

Code

public function testDeleteAll() {
  $backend_a = $this
    ->getCacheBackend();
  $backend_b = $this
    ->getCacheBackend('bootstrap');

  // Set both expiring and permanent keys.
  $backend_a
    ->set('test1', 1, Cache::PERMANENT);
  $backend_a
    ->set('test2', 3, time() + 1000);
  $backend_b
    ->set('test3', 4, Cache::PERMANENT);
  $backend_a
    ->deleteAll();
  $this
    ->assertTrue($backend_a
    ->get('test1'), 'First key has been persisted.');
  $this
    ->assertTrue($backend_a
    ->get('test2'), 'Second key has been persisted.');
  $this
    ->assertTrue($backend_b
    ->get('test3'), 'Item in other bin is preserved.');
}