function ClearTest::testFlushAllCaches

Tests drupal_flush_all_caches().

File

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

Class

ClearTest
Tests cache clearing methods.

Namespace

Drupal\system\Tests\Cache

Code

function testFlushAllCaches() {

  // Create cache entries for each flushed cache bin.
  $bins = module_invoke_all('cache_flush');
  $this
    ->assertTrue($bins, 'hook_cache_flush() returned bins to flush.');
  $bins = array_merge($bins, array(
    'menu',
  ));
  foreach ($bins as $id => $bin) {
    $cid = 'test_cid_clear' . $id;
    cache($bin)
      ->set($cid, $this->default_value);
  }

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