You are here

public function AuthcacheBlockTest::testMarkupSubstitution in Authenticated User Page Caching (Authcache) 7.2

Ensure that markup is substituted for authcache enabled blocks.

File

modules/authcache_block/authcache_block.test, line 123
Test cases for the Authcache Block module.

Class

AuthcacheBlockTest
Tests for markup substitution.

Code

public function testMarkupSubstitution() {
  $client_info = array(
    'authcache_p13n_test' => array(
      'title' => t('Test Client'),
      'enabled' => TRUE,
    ),
  );
  $this->stubmod
    ->hook('authcache_p13n_client', $client_info);
  $region = 'sidebar_first';
  $admin = $this
    ->drupalCreateUser(array(
    'administer blocks',
    'configure authcache blocks',
  ));
  $this
    ->drupalLogin($admin);
  $block = block_load('block', $this
    ->createCustomBlock());
  $this
    ->moveBlockToRegion($block, $region);
  $edit = array(
    'authcache_settings[status]' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/block/manage/' . $block->module . '/' . $block->delta . '/configure', $edit, t('Save block'));

  // Assert that config has no impact when user is not in authcache roles.
  $this
    ->drupalGet('node');
  $this
    ->assertBlockOnPage($block, $region);
  $this
    ->drupalLogout();
  $substituted_markup = $this
    ->randomName(8);
  $fragment_stub = HookStub::on('theme_authcache_p13n_fragment__authcache_p13n_test', $substituted_markup);

  // Assert that block is not on the page because authcache prepared the page
  // to be saved to the cache.
  $this
    ->drupalGet('node');
  $this
    ->assertNoBlockOnPage($block, $region);
  $this
    ->assertText($substituted_markup);
  $this
    ->assertStub($fragment_stub, HookStub::once());
}