You are here

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

Test that the flag markup is substituted by a partial.

Covers authcache_flag_entity_view_alter()

File

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

Class

AuthcacheFlagTest
Tests for markup substitution.

Code

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

  // M1: Visit the front page populated with two node having one flag each.
  $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('node');
  $this
    ->assertStub($assembly_stub, HookStub::times(1));
  $this
    ->assertStub($partial_stub, HookStub::times(2));

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

  // M1: Visit a full node 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('node/' . $this->node1->nid);
  $this
    ->assertStub($assembly_stub, HookStub::times(1));
  $this
    ->assertStub($partial_stub, HookStub::times(1));
}