ClearTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Cache/ClearTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Cache;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Cache\Cache;
class ClearTest extends CacheTestBase {
protected $defaultTheme = 'stark';
protected function setUp() {
$this->defaultBin = 'render';
$this->defaultValue = $this
->randomMachineName(10);
parent::setUp();
}
public function testFlushAllCaches() {
$bins = Cache::getBins();
$this
->assertNotEmpty($bins, 'Cache::getBins() returned bins to flush.');
foreach ($bins as $bin => $cache_backend) {
$cid = 'test_cid_clear' . $bin;
$cache_backend
->set($cid, $this->defaultValue);
}
drupal_flush_all_caches();
foreach ($bins as $bin => $cache_backend) {
$cid = 'test_cid_clear' . $bin;
$this
->assertFalse($this
->checkCacheExists($cid, $this->defaultValue, $bin), new FormattableMarkup('All cache entries removed from @bin.', [
'@bin' => $bin,
]));
}
}
}