public function GenericCacheBackendUnitTestBase::testInvalidate in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
- 9 core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
Tests Drupal\Core\Cache\CacheBackendInterface::invalidate() and Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
File
- core/
tests/ Drupal/ KernelTests/ Core/ Cache/ GenericCacheBackendUnitTestBase.php, line 506
Class
- GenericCacheBackendUnitTestBase
- Tests any cache backend.
Namespace
Drupal\KernelTests\Core\CacheCode
public function testInvalidate() {
$backend = $this
->getCacheBackend();
$backend
->set('test1', 1);
$backend
->set('test2', 2);
$backend
->set('test3', 2);
$backend
->set('test4', 2);
$reference = [
'test1',
'test2',
'test3',
'test4',
];
$cids = $reference;
$ret = $backend
->getMultiple($cids);
$this
->assertCount(4, $ret, 'Four items returned.');
$backend
->invalidate('test1');
$backend
->invalidateMultiple([
'test2',
'test3',
]);
$cids = $reference;
$ret = $backend
->getMultiple($cids);
$this
->assertCount(1, $ret, 'Only one item element returned.');
$cids = $reference;
$ret = $backend
->getMultiple($cids, TRUE);
$this
->assertCount(4, $ret, 'Four items returned.');
// Calling invalidateMultiple() with an empty array should not cause an
// error.
$this
->assertNull($backend
->invalidateMultiple([]));
}