Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / Cache / ClearTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Cache;
4
5 /**
6  * Tests our clearing is done the proper way.
7  *
8  * @group Cache
9  */
10 use Drupal\Core\Cache\Cache;
11
12 class ClearTest extends CacheTestBase {
13
14   protected function setUp() {
15     $this->defaultBin = 'render';
16     $this->defaultValue = $this->randomMachineName(10);
17
18     parent::setUp();
19   }
20
21   /**
22    * Tests drupal_flush_all_caches().
23    */
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);
31     }
32
33     // Remove all caches then make sure that they are cleared.
34     drupal_flush_all_caches();
35
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]));
39     }
40   }
41
42 }