You are here

function InactiveUserTest::drupalCreateInactiveUser in Inactive User 6

Same name and namespace in other branches
  1. 7 inactive_user.test \InactiveUserTest::drupalCreateInactiveUser()

Creates a drupal user and sets as inactive for a value of seconds.

Parameters

integer $seconds: number of seconds the user has been inactive.

Return value

stdclass Created user object.

4 calls to InactiveUserTest::drupalCreateInactiveUser()
InactiveUserTest::testInactiveUserBlocking in ./inactive_user.test
Check inactive user blocking and notifications are working
InactiveUserTest::testInactiveUserDeleting in ./inactive_user.test
Check inactive user deleting and notifications are working
InactiveUserTest::testInactiveUserNotification in ./inactive_user.test
Check inactive user and administrator notifications are working
InactiveUserTest::testInactiveUserWithContentDeleting in ./inactive_user.test
Check inactive user (with content) deleting and notifications are working

File

./inactive_user.test, line 453
Test the basic functions of the Inactive User module.

Class

InactiveUserTest
Inactive user module testcase.

Code

function drupalCreateInactiveUser($seconds = 0) {

  // Create a default user
  $account = $this
    ->drupalCreateUser();

  // Mark as inactive..
  $timestamp = time() - $seconds;
  db_query('UPDATE {users} SET login = %d, created = %d, access = %d WHERE uid = %d', $timestamp, $timestamp, $timestamp, $account->uid);

  // Verify inactivity.
  $access = db_result(db_query("SELECT access FROM {users} WHERE uid = %d", $account->uid));
  $this
    ->assertEqual($timestamp, $access, t('User successfully updated as inactive since %date.', array(
    '%date' => format_date($timestamp),
  )));
  return $account;
}