You are here

public function AuthcacheCommentTest::testNewMarkerSubstitutionWithNodeHistory in Authenticated User Page Caching (Authcache) 7.2

Test removal of the new marker.

Cover authcache_comment_preprocess_comment()

File

modules/authcache_comment/authcache_comment.test, line 384
Test cases for the Authcache Comment module.

Class

AuthcacheCommentTest
Tests for markup substitution.

Code

public function testNewMarkerSubstitutionWithNodeHistory() {
  $this->stubmod
    ->hook('authcache_p13n_client', array(
    'authcache_p13n_test' => array(
      'title' => t('Test Client'),
      'enabled' => TRUE,
    ),
  ));
  module_enable(array(
    'authcache_node_history',
  ));
  $this
    ->resetAll();

  // Simulate member1 visiting the node a minute ago.
  db_merge('history')
    ->key(array(
    'uid' => $this->member1->uid,
    'nid' => $this->node->nid,
  ))
    ->fields(array(
    'timestamp' => time() - 60,
  ))
    ->execute();

  // Login with member2 and post a comment.
  $this
    ->drupalLogin($this->member2);
  $comment = $this
    ->postComment($this->node, $this
    ->randomName(8));

  // Ensure that a new-marker is present handled by the authcache node-history
  // module.
  $this
    ->drupalLogin($this->member1);
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->assertTrue($this
    ->xpath('//span[contains(@class, :class)]', array(
    ':class' => 'new',
  )), 'New-marker on the page');
  $this
    ->assertTrue($this
    ->xpath('//span[contains(@class, :class)]', array(
    ':class' => 'authcache-node-history',
  )), 'New-marker handled by authcache node history module');
}