You are here

function CasLoginRedirectionTestCase::testNewUserLoginRedirection in CAS 6.3

Same name and namespace in other branches
  1. 7 cas.test \CasLoginRedirectionTestCase::testNewUserLoginRedirection()

Verify login redirection for a new user.

File

./cas.test, line 615
Tests for cas.module.

Class

CasLoginRedirectionTestCase
Test case to test user login behavior.

Code

function testNewUserLoginRedirection() {

  // Initial login without a destination goes to front page.
  $cas_name = $this
    ->randomName();
  $this
    ->casLogin($cas_name);
  $this
    ->assertUrl('');
  $this
    ->drupalLogout();

  // Initial login with redirection goes to specified destination.
  $node = $this
    ->drupalCreateNode();
  variable_set('cas_first_login_destination', "node/{$node->nid}");
  $cas_name = $this
    ->randomName();
  $account = $this
    ->casLogin($cas_name);
  $this
    ->assertUrl("node/{$node->nid}", array(
    'query' => array(
      'destination' => '',
    ),
  ));
  $this
    ->drupalLogout();

  // The second login should not be redirected.
  $this
    ->casLogin($cas_name);
  $this
    ->assertUrl('');
  $this
    ->drupalLogout();

  // Initial login with a admin-created account goes to the specified
  // destination.
  $account = $this
    ->casCreateUser();
  $this
    ->casLogin($account);
  $this
    ->assertUrl("node/{$node->nid}", array(
    'query' => array(
      'destination' => '',
    ),
  ));
  $this
    ->drupalLogout();

  // The second login should not be redirected.
  $this
    ->casLogin($account);
  $this
    ->assertUrl('');
  $this
    ->drupalLogout();
}