function CasTestHelper::casCreateUser in CAS 7
Same name and namespace in other branches
- 6.3 cas.test \CasTestHelper::casCreateUser()
Create a CAS user with the specified username.
Parameters
$cas_name: The CAS username. If omitted, a CAS username will be automatically generated.
$permissions: An array of permissions to assign to the created user.
Return value
A user account object. The CAS username is present in the cas_name field.
12 calls to CasTestHelper::casCreateUser()
- CasGatewayTestCase::testCasGatewayLoggedIn in ./cas.test 
- Test the CAS Gateway functionality of the user is logged in.
- CasLoginBlockTestCase::testCasLoginBlock in ./cas.test 
- Tests the visibility and functionality of the CAS login block.
- CasLoginRedirectionTestCase::testExistingUserLoginRedirection in ./cas.test 
- Verify login redirection for an existing user.
- CasLoginRedirectionTestCase::testNewUserLoginRedirection in ./cas.test 
- Verify login redirection for a new user.
- CasLogoutRedirectionTestCase::testLogoutRedirection in ./cas.test 
- Test redirection on user logout.
File
- ./cas.test, line 109 
- Tests for cas.module.
Class
- CasTestHelper
- @file Tests for cas.module.
Code
function casCreateUser($cas_name = NULL, $permissions = array(
  'access comments',
  'access content',
  'post comments',
  'skip comment approval',
)) {
  // Create user.
  $account = $this
    ->drupalCreateUser($permissions);
  $pass_raw = $account->pass_raw;
  // Add CAS username.
  if (empty($cas_name)) {
    $cas_name = $this
      ->randomName();
  }
  $edit['cas_name'] = $cas_name;
  $account = user_save($account, $edit);
  // Restore password.
  $account->pass_raw = $pass_raw;
  return $account;
}