public function GenericCacheBackendUnitTestBase::testInvalidate in Drupal 8
Same name in this branch
- 8 core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
- 8 core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
- 10 core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
Test Drupal\Core\Cache\CacheBackendInterface::invalidate() and Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
File
- core/
tests/ Drupal/ KernelTests/ Core/ Cache/ GenericCacheBackendUnitTestBase.php, line 499
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([]));
}