You are here

function SecurePagesTestCase::_testAnonymous in Secure Pages 6

Same name and namespace in other branches
  1. 8 securepages.test \SecurePagesTestCase::_testAnonymous()
  2. 6.2 securepages.test \SecurePagesTestCase::_testAnonymous()
  3. 7 securepages.test \SecurePagesTestCase::_testAnonymous()

Tests for anonymous browsing with securepages.

1 call to SecurePagesTestCase::_testAnonymous()
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 73
Provides SimpleTests for Secure Pages module.

Class

SecurePagesTestCase
@file Provides SimpleTests for Secure Pages module.

Code

function _testAnonymous() {

  // Visit the home page and /node with plain HTTP.
  $this
    ->drupalGet('');
  $this
    ->assertResponse(200);
  $this
    ->assertUrl(url('', array(
    'absolute' => TRUE,
  )));
  $this
    ->drupalGet('node');
  $this
    ->assertResponse(200);
  $this
    ->assertUrl(url('node', array(
    'absolute' => TRUE,
  )));

  // Visit the login page and confirm that browser is redirected to HTTPS.
  $this
    ->drupalGet('user');
  $this
    ->assertResponse(200);
  $this
    ->assertUrl($this
    ->_toHTTPS(url('user', array(
    'absolute' => TRUE,
  ))));

  // Visit the home page and /node with HTTPS and confirm that no redirection happens.
  $this
    ->drupalGet($this
    ->_toHTTPS(url('', array(
    'absolute' => TRUE,
  ))));
  $this
    ->assertResponse(200);
  $this
    ->assertUrl($this
    ->_toHTTPS(url('', array(
    'absolute' => TRUE,
  ))));
  $this
    ->drupalGet($this
    ->_toHTTPS(url('node', array(
    'absolute' => TRUE,
  ))));
  $this
    ->assertResponse(200);
  $this
    ->assertUrl($this
    ->_toHTTPS(url('node', array(
    'absolute' => TRUE,
  ))));

  // Enable "Switch back to http pages when there are no matches".
  variable_set('securepages_switch', TRUE);

  // Visit the home page and /node with HTTPS and confirm that switch-back happens.
  $this
    ->drupalGet($this
    ->_toHTTPS(url('', array(
    'absolute' => TRUE,
  ))));
  $this
    ->assertResponse(200);
  $this
    ->assertUrl(url('', array(
    'absolute' => TRUE,
  )));
  $this
    ->drupalGet($this
    ->_toHTTPS(url('node', array(
    'absolute' => TRUE,
  ))));
  $this
    ->assertResponse(200);
  $this
    ->assertUrl($this
    ->_toHTTP(url('node', array(
    'absolute' => TRUE,
  ))));

  // Clean up
  variable_del('securepages_pages');
}