You are here

public function AuthcacheFlagTest::testTaxonomyTermMarkupSubstitution in Authenticated User Page Caching (Authcache) 7.2

Test that the flag markup is substituted by a partial for taxonomy terms.

Covers authcache_flag_entity_view_alter()

File

modules/authcache_flag/authcache_flag.test, line 288
Test cases for the Authcache Flag module.

Class

AuthcacheFlagTest
Tests for markup substitution.

Code

public function testTaxonomyTermMarkupSubstitution() {
  $this->stubmod
    ->hook('authcache_p13n_client', array(
    'authcache_p13n_test' => array(
      'title' => t('Test Client'),
      'enabled' => TRUE,
    ),
  ));
  $this
    ->drupalLogin($this->member1);

  // M1: Visit a full term view.
  $assembly_markup = $this
    ->randomName(8);
  $assembly_stub = HookStub::on('theme_authcache_p13n_assembly__authcache_p13n_test', $assembly_markup);
  $partial_markup = $this
    ->randomName(8);
  $partial_stub = HookStub::on('theme_authcache_p13n_partial__authcache_p13n_test', $partial_markup);
  $this
    ->drupalGet('taxonomy/term/' . $this->term->tid);
  $this
    ->assertStub($assembly_stub, HookStub::times(1));
  $this
    ->assertStub($partial_stub, HookStub::times(1));

  // Load flag and change it such that it will be displayed as a pseudo field.
  $flag = flag_get_flag($this->termFlag->name);
  $flag->show_in_links = array();
  $flag->show_as_field = 1;
  $this->termFlag = $this
    ->saveFlag($flag);

  // M1: Visit a full term view.
  $assembly_markup = $this
    ->randomName(8);
  $assembly_stub = HookStub::on('theme_authcache_p13n_assembly__authcache_p13n_test', $assembly_markup);
  $partial_markup = $this
    ->randomName(8);
  $partial_stub = HookStub::on('theme_authcache_p13n_partial__authcache_p13n_test', $partial_markup);
  $this
    ->drupalGet('taxonomy/term/' . $this->term->tid);
  $this
    ->assertStub($assembly_stub, HookStub::times(1));
  $this
    ->assertStub($partial_stub, HookStub::times(1));
}