public function GenericCacheBackendUnitTestBase::testInvalidateAll

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

File

drupal/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php, line 528
Definition of Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase.

Class

GenericCacheBackendUnitTestBase
Tests any cache backend.

Namespace

Drupal\system\Tests\Cache

Code

public function testInvalidateAll() {
  $backend = $this
    ->getCacheBackend();

  // Set both expiring and permanent keys.
  $backend
    ->set('test1', 1, CacheBackendInterface::CACHE_PERMANENT);
  $backend
    ->set('test2', 3, time() + 1000);
  $backend
    ->invalidateAll();
  $this
    ->assertFalse($backend
    ->get('test1'), 'First key has been invalidated.');
  $this
    ->assertFalse($backend
    ->get('test2'), 'Second key has been invalidated.');
  $this
    ->assertTrue($backend
    ->get('test1', TRUE), 'First key has not been deleted.');
  $this
    ->assertTrue($backend
    ->get('test2', TRUE), 'Second key has not been deleted.');
}