You are here

function ClearTest::testFlushAllCaches in Zircon Profile 8

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

Tests drupal_flush_all_caches().

File

core/modules/system/src/Tests/Cache/ClearTest.php, line 29
Contains \Drupal\system\Tests\Cache\ClearTest.

Class

ClearTest

Namespace

Drupal\system\Tests\Cache

Code

function testFlushAllCaches() {

  // Create cache entries for each flushed cache bin.
  $bins = Cache::getBins();
  $this
    ->assertTrue($bins, 'Cache::getBins() returned bins to flush.');
  foreach ($bins as $bin => $cache_backend) {
    $cid = 'test_cid_clear' . $bin;
    $cache_backend
      ->set($cid, $this->defaultValue);
  }

  // Remove all caches then make sure that they are cleared.
  drupal_flush_all_caches();
  foreach ($bins as $bin => $cache_backend) {
    $cid = 'test_cid_clear' . $bin;
    $this
      ->assertFalse($this
      ->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', array(
      '@bin' => $bin,
    )));
  }
}