3 namespace Drupal\Tests\system\Functional\Cache;
6 * Tests our clearing is done the proper way.
10 use Drupal\Core\Cache\Cache;
12 class ClearTest extends CacheTestBase {
14 protected function setUp() {
15 $this->defaultBin = 'render';
16 $this->defaultValue = $this->randomMachineName(10);
22 * Tests drupal_flush_all_caches().
24 public function testFlushAllCaches() {
25 // Create cache entries for each flushed cache bin.
26 $bins = Cache::getBins();
27 $this->assertTrue($bins, 'Cache::getBins() returned bins to flush.');
28 foreach ($bins as $bin => $cache_backend) {
29 $cid = 'test_cid_clear' . $bin;
30 $cache_backend->set($cid, $this->defaultValue);
33 // Remove all caches then make sure that they are cleared.
34 drupal_flush_all_caches();
36 foreach ($bins as $bin => $cache_backend) {
37 $cid = 'test_cid_clear' . $bin;
38 $this->assertFalse($this->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', ['@bin' => $bin]));