You are here

function MemCacheClearCase::testClearWildcardOnSeparatePages in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/tests/memcache.test \MemCacheClearCase::testClearWildcardOnSeparatePages()

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

File

modules/memcache/tests/memcache.test, line 451

Class

MemCacheClearCase
Test cache clearing methods.

Code

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/wildcard-clear/' . $random_wildcard);
  $data = $this
    ->drupalGetAJAX('memcache-test/get/' . $random_key);
  $this
    ->assertFalse($data, 'Cache 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.');
}