You are here

public function MemCacheClearCase::testClearWildcardOnSeparatePages in Memcache API and Integration 7

Test wildcard flushing on separate pages to ensure no static cache is used.

File

tests/memcache.test, line 661
Test cases for the memcache cache backend.

Class

MemCacheClearCase
Test cache clearing methods.

Code

public function testClearWildcardOnSeparatePages() {
  $random_wildcard = $this
    ->randomName(2) . ':' . $this
    ->randomName(3);
  $random_key = $random_wildcard . ':' . $this
    ->randomName(4) . ':' . $this
    ->randomName(2);
  $random_value = $this
    ->randomName();
  $this
    ->drupalGetAJAX('memcache-test/clear-cache');
  $data = $this
    ->drupalGetAJAX('memcache-test/set/' . $random_key . '/' . $random_value);
  $this
    ->assertTrue(is_array($data), 'Cache has data.');
  $this
    ->assertEqual($random_key, $data['cid'], 'Cache keys match.');
  $this
    ->assertEqual($random_value, $data['data'], 'Cache values match.');
  $data = $this
    ->drupalGetAJAX('memcache-test/get/' . $random_key);
  $this
    ->assertEqual($random_key, $data['cid'], 'Cache keys match.');
  $this
    ->assertEqual($random_value, $data['data'], 'Cache values match.');
  $this
    ->drupalGet('memcache-test/clear/' . $random_key);
  $data = $this
    ->drupalGetAJAX('memcache-test/get/' . $random_key);
  $this
    ->assertFalse($data, 'Cache value at specific key was properly flushed.');
  $data = $this
    ->drupalGetAJAX('memcache-test/set/' . $random_key . '/' . $random_value);
  $this
    ->assertTrue(is_array($data), 'Cache has data.');
  $this
    ->assertEqual($random_key, $data['cid'], 'Cache keys match.');
  $this
    ->assertEqual($random_value, $data['data'], 'Cache values match.');
  $data = $this
    ->drupalGetAJAX('memcache-test/get/' . $random_key);
  $this
    ->assertEqual($random_key, $data['cid'], 'Cache keys match.');
  $this
    ->assertEqual($random_value, $data['data'], 'Cache values match.');
  $this
    ->drupalGet('memcache-test/wildcard-clear/' . $random_wildcard);
  $data = $this
    ->drupalGetAJAX('memcache-test/get/' . $random_key);
  $this
    ->assertFalse($data, 'Cache was properly flushed.');
}