You are here

function TokenActionsTestCase::testUserActions in Token 6

Test user actions and triggers.

File

./token_actions.test, line 26
Tests for the token_actions module.

Class

TokenActionsTestCase
@file Tests for the token_actions module.

Code

function testUserActions() {
  $insert_action = $this
    ->createAction('token_actions_message_action', array(
    'message' => 'Yay [site-name] has a new user [user] with an ID of [uid] and e-mail address of [mail]!',
  ));
  $this
    ->assignTriggerAction('user', 'insert', $insert_action);

  // Create a user to trigger the action.
  $edit = array();
  $edit['name'] = $this
    ->randomName();
  $edit['mail'] = $edit['name'] . '@example.com';
  $edit['pass[pass1]'] = $this
    ->randomName();
  $edit['pass[pass2]'] = $edit['pass[pass1]'];
  $this
    ->drupalPost('admin/user/user/create', $edit, t('Create new account'));
  $account = user_load(array(
    'name' => $edit['name'],
  ));
  $this
    ->assertText("Yay Drupal has a new user {$account->name} with an ID of {$account->uid} and e-mail address of {$account->mail}!", 'Tokenized message displays');
}