class ClearTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/Cache/ClearTest.php \Drupal\Tests\system\Functional\Cache\ClearTest
- 10 core/modules/system/tests/src/Functional/Cache/ClearTest.php \Drupal\Tests\system\Functional\Cache\ClearTest
- 8.9.x core/modules/system/tests/src/Functional/Cache/ClearTest.php \Drupal\Tests\system\Functional\Cache\ClearTest
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Cache\CacheTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\system\Functional\Cache\ClearTest extends \Drupal\Tests\system\Functional\Cache\CacheTestBase
- class \Drupal\Tests\system\Functional\Cache\CacheTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ClearTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Cache/ ClearTest.php, line 13
Namespace
Drupal\Tests\system\Functional\CacheView source
class ClearTest extends CacheTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$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->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);
}
// 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), new FormattableMarkup('All cache entries removed from @bin.', [
'@bin' => $bin,
]));
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.