You are here

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

Test the edit-link when edit own is allowed.

Cover authcache_comment_comment_view_alter()

File

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

Class

AuthcacheCommentTest
Tests for markup substitution.

Code

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

  // The role of M2 has the 'edit own comments' permission. Therefore
  // Authcache Comment should substitute the markup for edit-links.
  $this
    ->drupalLogin($this->member2);
  $comment = $this
    ->postComment($this->node, $this
    ->randomName(8));
  $this
    ->drupalGet('node/' . $this->node->nid);

  // See DrupalWebTestCase::assertLink().
  $label = 'edit';
  $links = $this
    ->xpath('//a[normalize-space(text())=:label and contains(@class, :authcache_class) and contains(@class, :hidden_class)]', array(
    ':label' => $label,
    ':authcache_class' => 'authcache-comment-edit',
    ':hidden_class' => 'element-hidden',
  ));
  $this
    ->assert(isset($links[0]), t('Hidden link with label %label found.', array(
    '%label' => $label,
  )));
  $this
    ->assertLink('edit');
}