You are here

function VarnishCacheInvalidationCase::testCommentCacheExpiration in Varnish 6

Test that makes sure that the comment expiration works as expected.

File

./varnish.test, line 249
Tests the basic functionality of Varnish.

Class

VarnishCacheInvalidationCase

Code

function testCommentCacheExpiration() {

  // Create a node.
  $node = $this
    ->drupalCreateNode(array(
    'promote' => 1,
    'type' => 'article',
  ));

  // Create a user.
  $user = $this
    ->drupalCreateUser();

  // Cache the standard node listing.
  $this
    ->drupalGet('node/' . $node->nid);

  // Create a comment on the node.
  $comment = $this
    ->createComment(array(
    'nid' => $node->nid,
  ), $user);
  $this
    ->assertNotEqual($comment, FALSE, t('Comment was created without problems.'));

  // Check the node again. It should be updated with the new content.
  $data = $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertText($comment['subject'], t('The comment subject %subject was
      found', array(
    '%subject' => $comment['subject'],
  )));

  // Update the comment and see that it gets updated on the node page.
  $comment['subject'] = $this
    ->randomName();
  comment_save($comment);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertText($comment['subject'], t('The changed comment subject
      %subject was found', array(
    '%subject' => $comment['subject'],
  )));

  // Delete the comment and see that it gets removed from the node page.
  $this
    ->deleteComment($comment);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertNoText($comment['subject'], t('The comment subject
      %subject of the deleted node was not found.', array(
    '%subject' => $comment['subject'],
  )));
}