function UserTokenReplaceTestCase::testAnonymousUserTokenReplacement

Uses an anonymous user, then tests the tokens generated from it.

File

modules/user/user.test, line 2718

Class

UserTokenReplaceTestCase
Test user token replacement in strings.

Code

function testAnonymousUserTokenReplacement() {
  global $language;
  // Load anonymous user data.
  $account = drupal_anonymous_user();
  // Generate and test sanitized tokens.
  $tests = array();
  $tests['[user:mail]'] = '';
  foreach ($tests as $input => $expected) {
    $output = token_replace($input, array(
      'user' => $account,
    ), array(
      'language' => $language,
    ));
    $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array(
      '%token' => $input,
    )));
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.