
| Current Path : /var/www/html/dataninja.cn/core/modules/system/tests/src/Functional/Cache/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/dataninja.cn/core/modules/system/tests/src/Functional/Cache/ClearTest.php |
<?php
namespace Drupal\Tests\system\Functional\Cache;
/**
* Tests our clearing is done the proper way.
*
* @group Cache
*/
use Drupal\Core\Cache\Cache;
class ClearTest extends CacheTestBase {
protected function setUp() {
$this->defaultBin = 'render';
$this->defaultValue = $this->randomMachineName(10);
parent::setUp();
}
/**
* Tests drupal_flush_all_caches().
*/
public function testFlushAllCaches() {
// Create cache entries for each flushed cache bin.
$bins = Cache::getBins();
$this->assertTrue($bins, 'Cache::getBins() returned bins to flush.');
foreach ($bins as $bin => $cache_backend) {
$cid = 'test_cid_clear' . $bin;
$cache_backend->set($cid, $this->defaultValue);
}
// 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->defaultValue, $bin), format_string('All cache entries removed from @bin.', ['@bin' => $bin]));
}
}
}