You are here

function SecurepagesTest::_testCachedResponse in Secure Pages 8

1 call to SecurepagesTest::_testCachedResponse()
SecurepagesTest::testSecurePages in src/Tests/SecurepagesTest.php
Runs all the tests in a sequence to avoid multiple re-installs.

File

src/Tests/SecurepagesTest.php, line 214
Contains \Drupal\securepages\Tests\SecurepagesTest.

Class

SecurepagesTest
Test Secure Pages redirects.

Namespace

Drupal\securepages\Tests

Code

function _testCachedResponse() {

  // Enable the page cache and fetch the login page.
  $this
    ->installModule('page_cache');
  $url = Url::fromRoute('user.login', [], [
    'absolute' => TRUE,
    'https' => FALSE,
  ]);
  $this
    ->drupalGet($url);

  // Short-circuit redirects within the simpletest browser.
  $maximum_redirects = $this->maximumRedirects;
  $this->maximumRedirects = 0;
  $this
    ->drupalGet($url);
  $this
    ->assertResponse(302);
  $this
    ->assertEqual($this
    ->drupalGetHeader('Location'), Url::fromRoute('user.login', [], [
    'https' => TRUE,
    'absolute' => TRUE,
  ])
    ->toString());
  $this
    ->assertEqual($this
    ->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');

  // Clean up.
  $this->maximumRedirects = $maximum_redirects;
  $this
    ->uninstallModule('page_cache');
}