function BlockCacheTestCase::testCachePerUser in Drupal 7
Test DRUPAL_CACHE_PER_USER.
File
- modules/
block/ block.test, line 613 - Tests for block.module.
Class
- BlockCacheTestCase
- Test block caching.
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, 'Block content displays.');
$old_content = $current_content;
$current_content = $this
->randomName();
variable_set('block_test_content', $current_content);
$this
->drupalGet('');
$this
->assertText($old_content, 'Block is served from per-user cache.');
$this
->drupalLogin($this->normal_user_alt);
$this
->drupalGet('');
$this
->assertText($current_content, 'Per-user block cache is not served for other users.');
$this
->drupalLogin($this->normal_user);
$this
->drupalGet('');
$this
->assertText($old_content, 'Per-user block cache is persistent.');
}