You are here

function CasUserAdminTestCase::testUserAdd in CAS 6.3

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

Tests adding a user with a CAS username in the administrative interface.

File

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

Class

CasUserAdminTestCase

Code

function testUserAdd() {
  $this
    ->drupalLogin($this->admin_user);

  // Register a user with a CAS username.
  $cas_name = $this
    ->randomName();
  $edit = array(
    'name' => $this
      ->randomName(),
    'mail' => $this
      ->randomName() . '@example.com',
    'cas_name' => $cas_name,
    'pass[pass1]' => $pass = $this
      ->randomString(),
    'pass[pass2]' => $pass,
    'notify' => FALSE,
  );
  $this
    ->drupalPost('admin/user/user/create', $edit, t('Create new account'));
  $this
    ->assertText(t('Created a new user account for @name. No e-mail has been sent.', array(
    '@name' => $edit['name'],
  )), 'User created');
  $this
    ->drupalGet('admin/user/user');
  $this
    ->assertText($edit['name'], 'User found in list of users');
  $this
    ->assertText($edit['cas_name'], 'CAS username found in list of users');

  // Verify that duplicate CAS usernames are not allowed.
  $edit = array(
    'name' => $this
      ->randomName(),
    'mail' => $this
      ->randomName() . '@example.com',
    'cas_name' => $cas_name,
    'pass[pass1]' => $pass = $this
      ->randomString(),
    'pass[pass2]' => $pass,
    'notify' => FALSE,
  );
  $this
    ->drupalPost('admin/user/user/create', $edit, t('Create new account'));
  $this
    ->assertText(t('The CAS username is already in use on this site.'), 'CAS username already in use.');
}