You are here

function VarnishCacheInvalidationCase::testNoVarnishCacheExpiration in Varnish 6

Test that makes sure that the varnish cache doesn't get invalidated when the varnish_cache_clear options is set to 0.

File

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

Class

VarnishCacheInvalidationCase

Code

function testNoVarnishCacheExpiration() {

  // Tell Varnish Module to not expire anything.
  variable_set('varnish_cache_clear', 0);

  // Create a node.
  $node = $this
    ->drupalCreateNode();

  // Cache it in varnish by going to the node.
  $content = $this
    ->drupalGet('node/' . $node->nid);

  // The title should be what we expect, otherwise, something
  // is horribly wrong.
  $this
    ->assertText($node->title, t('The node title correct.'));
  $old_title = $node->title;

  // Change the node title
  $node->title = $this
    ->randomName(8);
  node_save($node);

  // Go to the node again. The title should not have changed.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertText($old_title, t('The node title did not change when
     varnish is set to not invalidate the cache.'));
}