You are here

function CacheClearCase::testClearWildcard in Drupal 7

Test clearing using wildcard.

File

modules/simpletest/tests/cache.test, line 263

Class

CacheClearCase
Test cache clearing methods.

Code

function testClearWildcard() {
  cache_set('test_cid_clear1', $this->default_value, $this->default_bin);
  cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
  $this
    ->assertTrue($this
    ->checkCacheExists('test_cid_clear1', $this->default_value) && $this
    ->checkCacheExists('test_cid_clear2', $this->default_value), 'Two caches were created for checking cid "*" with wildcard true.');
  cache_clear_all('*', $this->default_bin, TRUE);
  $this
    ->assertFalse($this
    ->checkCacheExists('test_cid_clear1', $this->default_value) || $this
    ->checkCacheExists('test_cid_clear2', $this->default_value), 'Two caches removed after clearing cid "*" with wildcard true.');
  cache_set('test_cid_clear1', $this->default_value, $this->default_bin);
  cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
  $this
    ->assertTrue($this
    ->checkCacheExists('test_cid_clear1', $this->default_value) && $this
    ->checkCacheExists('test_cid_clear2', $this->default_value), 'Two caches were created for checking cid substring with wildcard true.');
  cache_clear_all('test_', $this->default_bin, TRUE);
  $this
    ->assertFalse($this
    ->checkCacheExists('test_cid_clear1', $this->default_value) || $this
    ->checkCacheExists('test_cid_clear2', $this->default_value), 'Two caches removed after clearing cid substring with wildcard true.');
}