You are here

function SecurePagesTestCase::_testCachedResponse in Secure Pages 6.2

Same name and namespace in other branches
  1. 8 securepages.test \SecurePagesTestCase::_testCachedResponse()
  2. 6 securepages.test \SecurePagesTestCase::_testCachedResponse()
  3. 7 securepages.test \SecurePagesTestCase::_testCachedResponse()
1 call to SecurePagesTestCase::_testCachedResponse()
SecurePagesTestCase::testSecurePages in ./securepages.test
Runs all the test functions. These are run from a single outer function to avoid * multiple re-installs by simpletest.

File

./securepages.test, line 206
Provides SimpleTests for Secure Pages module.

Class

SecurePagesTestCase
@file Provides SimpleTests for Secure Pages module.

Code

function _testCachedResponse() {

  // Enable the page cache and fetch the login page.
  variable_set('cache', TRUE);
  $url = url('user/login', array(
    'absolute' => TRUE,
  ));
  $this
    ->drupalGet($url);

  // Short-circuit redirects within the simpletest browser.
  variable_set('simpletest_maximum_redirects', 0);
  $this
    ->drupalGet($url);
  $this
    ->assertResponse(302);
  $this
    ->assertEqual($this
    ->drupalGetHeader('Location'), $this
    ->_toHTTPS(url('user/login', array(
    'absolute' => TRUE,
  ))));
  $cache = cache_get($url, 'cache_page');
  $this
    ->assertTrue(strstr($cache->headers, 'Status: 3'), '3XX redirect was found in the cache.');

  // Clean up
  variable_del('cache');
  variable_del('simpletest_maximum_redirects');
}