function ClearTest::testFlushAllCaches

Tests drupal_flush_all_caches().

File

drupal/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php, line 35
Definition of 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_get_bins() returned bins to flush.');
  $bins['menu'] = $this->container
    ->get('cache.menu');
  foreach ($bins as $bin => $cache_backend) {
    $cid = 'test_cid_clear' . $bin;
    $cache_backend
      ->set($cid, $this->default_value);
  }

  // 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->default_value, $bin), format_string('All cache entries removed from @bin.', array(
      '@bin' => $bin,
    )));
  }
}