You are here

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

Test the edit-link for admin role.

Cover authcache_comment_comment_view_alter()

File

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

Class

AuthcacheCommentTest
Tests for markup substitution.

Code

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

  // The editor has permission to administrate comments, therefore there is no
  // point in replacing edit links - they will be rendered anyway.
  $this
    ->drupalLogin($this->editor);
  $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');
}