You are here

public function BlockCacheTest::testCachePerUser in MongoDB 7

Test DRUPAL_CACHE_PER_USER.

File

mongodb_block_ui/src/Tests/BlockCacheTest.php, line 157

Class

BlockCacheTest
Test block caching.

Namespace

Drupal\mongodb_block_ui\Tests

Code

public function testCachePerUser() {
  $this
    ->setCacheMode(DRUPAL_CACHE_PER_USER);
  $current_content = $this
    ->randomName();
  variable_set('block_test_content', $current_content);
  $this
    ->drupalLogin($this->normalUser);
  $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->normalUserAlt);
  $this
    ->drupalGet('');
  $this
    ->assertText($current_content, t('Per-user block cache is not served for other users.'));
  $this
    ->drupalLogin($this->normalUser);
  $this
    ->drupalGet('');
  $this
    ->assertText($old_content, t('Per-user block cache is persistent.'));
}