You are here

public function GenericCacheBackendUnitTestBase::testDeleteAll in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase::testDeleteAll()

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

1 call to GenericCacheBackendUnitTestBase::testDeleteAll()
ApcuBackendUnitTest::testDeleteAll in core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
Test Drupal\Core\Cache\CacheBackendInterface::deleteAll().
1 method overrides GenericCacheBackendUnitTestBase::testDeleteAll()
ApcuBackendUnitTest::testDeleteAll in core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
Test Drupal\Core\Cache\CacheBackendInterface::deleteAll().

File

core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php, line 479
Contains \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase.

Class

GenericCacheBackendUnitTestBase
Tests any cache backend.

Namespace

Drupal\system\Tests\Cache

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
    ->assertFalse($backend_a
    ->get('test1'), 'First key has been deleted.');
  $this
    ->assertFalse($backend_a
    ->get('test2'), 'Second key has been deleted.');
  $this
    ->assertTrue($backend_b
    ->get('test3'), 'Item in other bin is preserved.');
}