function GenericCacheBackendUnitTestBase::testInvalidate

Test Drupal\Core\Cache\CacheBackendInterface::invalidate() and Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php, line 440
Definition of Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase.

Class

GenericCacheBackendUnitTestBase
Tests any cache backend.

Namespace

Drupal\system\Tests\Cache

Code

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.');
}