function GenericCacheBackendUnitTestBase::testInvalidate
Same name in other branches
- 8.9.x core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
- 8.9.x 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()
- 11.x core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::testInvalidate()
@covers \Drupal\Core\Cache\ApcuBackend::getMultiple @covers \Drupal\Core\Cache\BackendChain::getMultiple @covers \Drupal\Core\Cache\ChainedFastBackend::getMultiple @covers \Drupal\Core\Cache\DatabaseBackend::getMultiple @covers \Drupal\Core\Cache\MemoryBackend::getMultiple @covers \Drupal\Core\Cache\PhpBackend::getMultiple @covers \Drupal\Core\Cache\ApcuBackend::invalidateMultiple @covers \Drupal\Core\Cache\BackendChain::invalidateMultiple @covers \Drupal\Core\Cache\ChainedFastBackend::invalidateMultiple @covers \Drupal\Core\Cache\DatabaseBackend::invalidateMultiple @covers \Drupal\Core\Cache\MemoryBackend::invalidateMultiple @covers \Drupal\Core\Cache\PhpBackend::invalidateMultiple
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Cache/ GenericCacheBackendUnitTestBase.php, line 532
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([]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.