public function GenericCacheBackendUnitTestBase::testInvalidateAll in Drupal 8
Same name in this branch
- 8 core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidateAll()
- 8 core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase::testInvalidateAll()
Test Drupal\Core\Cache\CacheBackendInterface::invalidateAll().
File
- core/
modules/ system/ src/ Tests/ Cache/ GenericCacheBackendUnitTestBase.php, line 593
Class
- GenericCacheBackendUnitTestBase
- Tests any cache backend.
Namespace
Drupal\system\Tests\CacheCode
public function testInvalidateAll() {
$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
->invalidateAll();
$this
->assertFalse($backend_a
->get('test1'), 'First key has been invalidated.');
$this
->assertFalse($backend_a
->get('test2'), 'Second key has been invalidated.');
$this
->assertTrue($backend_b
->get('test3'), 'Item in other bin is preserved.');
$this
->assertTrue($backend_a
->get('test1', TRUE), 'First key has not been deleted.');
$this
->assertTrue($backend_a
->get('test2', TRUE), 'Second key has not been deleted.');
}