BlockCacheTestCase::testCachePerUser

7 block.test BlockCacheTestCase::testCachePerUser()
8 block.test BlockCacheTestCase::testCachePerUser()

Test DRUPAL_CACHE_PER_USER.

File

modules/block/block.test, line 613
Tests for block.module.

Code

function testCachePerUser() {
  $this->setCacheMode(DRUPAL_CACHE_PER_USER);
  $current_content = $this->randomName();
  variable_set('block_test_content', $current_content);
  $this->drupalLogin($this->normal_user);

  $this->drupalGet('');
  $this->assertText($current_content, t('Block content displays.'));

  $old_content = $current_content;
  $current_content = $this->randomName();
  variable_set('block_test_content', $current_content);

  $this->drupalGet('');
  $this->assertText($old_content, t('Block is served from per-user cache.'));

  $this->drupalLogin($this->normal_user_alt);
  $this->drupalGet('');
  $this->assertText($current_content, t('Per-user block cache is not served for other users.'));

  $this->drupalLogin($this->normal_user);
  $this->drupalGet('');
  $this->assertText($old_content, t('Per-user block cache is persistent.'));
}
Login or register to post comments