You are here

function SecurePagesTestCase::_testPathAlias in Secure Pages 7

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

Test redirection on aliased paths.

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

Class

SecurePagesTestCase
@file Provides SimpleTests for Secure Pages module.

Code

function _testPathAlias() {
  variable_set('securepages_pages', "node/*\nuser*");

  // Create test user and login.
  $web_user = $this
    ->drupalCreateUser(array(
    'create page content',
    'edit own page content',
    'administer url aliases',
    'create url aliases',
  ));
  $this
    ->drupalLogin($web_user);

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

  // Create alias.
  $edit = array();
  $edit['source'] = 'node/' . $node->nid;
  $edit['alias'] = $this
    ->randomName(8);
  $this
    ->drupalPost('admin/config/search/path/add', $edit, t('Save'));

  // Short-circuit redirects within the simpletest browser.
  variable_set('simpletest_maximum_redirects', 0);
  $this
    ->drupalGet($edit['alias'], array(
    'absolute' => TRUE,
    'https' => FALSE,
  ));
  $this
    ->assertResponse(302);
  $this
    ->assertEqual($this
    ->drupalGetHeader('Location'), url($edit['alias'], array(
    'https' => TRUE,
    'absolute' => TRUE,
  )));

  // Clean up
  variable_del('simpletest_maximum_redirects');
  $this
    ->drupalLogout();
  variable_del('securepages_pages');
}