You are here

function CasLoginBlockTestCase::testCasLoginBlock in CAS 7

Same name and namespace in other branches
  1. 6.3 cas.test \CasLoginBlockTestCase::testCasLoginBlock()

Tests the visibility and functionality of the CAS login block.

File

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

Class

CasLoginBlockTestCase
Tests the visibility and functionality of the CAS login block.

Code

function testCasLoginBlock() {
  $account = $this
    ->casCreateUser();
  $this
    ->setCasUser($account);

  // Verify that the block is shown on some pages, but not on others.
  $this
    ->drupalGet('');
  $this
    ->assertCasLoginBlock(TRUE);
  $this
    ->drupalGet('user');
  $this
    ->assertCasLoginBlock(FALSE);
  $this
    ->drupalGet('user/1');
  $this
    ->assertCasLoginBlock(TRUE);

  // Log in using the login block, and verify redirection works.
  $edit = array();
  $submit = t(variable_get('cas_login_invite', CAS_LOGIN_INVITE_DEFAULT));
  $this
    ->drupalPost('', $edit, $submit);
  $this
    ->assertLoggedIn($account);
  $this
    ->assertUrl('node');

  // Block should not be shown to logged in users.
  $this
    ->assertCasLoginBlock(FALSE);
}