You are here

function InactiveUserTest::drupalCreateInactiveUser in Inactive User 7

Same name and namespace in other branches
  1. 6 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 456
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_update('users')
    ->fields(array(
    'login' => $timestamp,
    'created' => $timestamp,
    'access' => $timestamp,
  ))
    ->condition('uid', $account->uid)
    ->execute();

  // Verify inactivity.
  $access = db_select('users', 'u')
    ->fields('u', array(
    'access',
  ))
    ->condition('u.uid', $account->uid)
    ->execute()
    ->fetchField();
  $this
    ->assertEqual($timestamp, $access, t('User successfully updated as inactive since %date.', array(
    '%date' => format_date($timestamp),
  )));
  return $account;
}