You are here

function GenericCacheBackendUnitTestBase::testInvalidate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase::testInvalidate()

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

1 call to GenericCacheBackendUnitTestBase::testInvalidate()
ApcuBackendUnitTest::testInvalidate in core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
Test Drupal\Core\Cache\CacheBackendInterface::invalidate() and Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
1 method overrides GenericCacheBackendUnitTestBase::testInvalidate()
ApcuBackendUnitTest::testInvalidate in core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
Test Drupal\Core\Cache\CacheBackendInterface::invalidate() and Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().

File

core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php, line 499
Contains \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.');

  // Calling invalidateMultiple() with an empty array should not cause an
  // error.
  $this
    ->assertFalse($backend
    ->invalidateMultiple(array()));
}