Test Drupal\Core\Cache\CacheBackendInterface::invalidate() and Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
function testInvalidate() {
$backend = $this
->getCacheBackend();
$backend
->set('test1', 1);
$backend
->set('test2', 2);
$backend
->set('test3', 2);
$backend
->set('test4', 2);
$reference = array(
'test1',
'test2',
'test3',
'test4',
);
$cids = $reference;
$ret = $backend
->getMultiple($cids);
$this
->assertEqual(count($ret), 4, 'Four items returned.');
$backend
->invalidate('test1');
$backend
->invalidateMultiple(array(
'test2',
'test3',
));
$cids = $reference;
$ret = $backend
->getMultiple($cids);
$this
->assertEqual(count($ret), 1, 'Only one item element returned.');
$cids = $reference;
$ret = $backend
->getMultiple($cids, TRUE);
$this
->assertEqual(count($ret), 4, 'Four items returned.');
}