function BlockCacheTest::testCachePerPage

Test DRUPAL_CACHE_PER_PAGE.

File

drupal/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php, line 173
Definition of Drupal\block\Tests\BlockCacheTest.

Class

BlockCacheTest
Test block caching.

Namespace

Drupal\block\Tests

Code

function testCachePerPage() {
  $this
    ->setCacheMode(DRUPAL_CACHE_PER_PAGE);
  $current_content = $this
    ->randomName();
  state()
    ->set('block_test.content', $current_content);
  $this
    ->drupalGet('node');
  $this
    ->assertText($current_content, 'Block content displays on the node page.');
  $old_content = $current_content;
  $current_content = $this
    ->randomName();
  state()
    ->set('block_test.content', $current_content);
  $this
    ->drupalGet('user');
  $this
    ->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.');
  $this
    ->drupalGet('node');
  $this
    ->assertText($old_content, 'Block content cached for the node page.');
}