You are here

function VarnishCacheInvalidationCase::testUserCacheExpiration in Varnish 6

Test that makes sure that the user cache expiration works as intended.

File

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

Class

VarnishCacheInvalidationCase

Code

function testUserCacheExpiration() {

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

  // Cache it in varnish.
  $this
    ->drupalGet('user/' . $user->uid);

  // Make sure the user name is present.
  $this
    ->assertText($user->name, t('The user name %name
      is present on the profile page.', array(
    '%name' => $user->name,
  )));

  // Change the user name.
  $user->name = $this
    ->randomName();
  user_save($user, (array) $user);

  // Go to the user page. It cache should have been invalidated.
  $this
    ->drupalGet('user/' . $user->uid);
  $this
    ->assertText($user->name, t('The changed user name %name is
      present on the profile page.', array(
    '%name' => $user->name,
  )));
}