Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function UserCancelTestCase::testUserCancelByAdmin

Create an administrative user and delete another user.

File

modules/user/user.test, line 1286

Class

UserCancelTestCase
Test cancelling a user.

Code

function testUserCancelByAdmin() {
 variable_set ('user_cancel_method', 'user_cancel_reassign');
 // Create a regular user.
 $account = $this->drupalCreateUser (array());
 // Create administrative user.
 $admin_user = $this->drupalCreateUser (array(
 'administer users',
 ));
 $this->drupalLogin ($admin_user);
 // Delete regular user.
 $this->drupalGet ('user/' . $account->uid . '/edit');
 $this->drupalPost (NULL, NULL, t ('Cancel account'));
 $this->assertRaw (t ('Are you sure you want to cancel the account %name?', array(
 '%name' => $account->name ,
 )), 'Confirmation form to cancel account displayed.');
 $this->assertText (t ('Select the method to cancel the account above.'), 'Allows to select account cancellation method.');
 // Confirm deletion.
 $this->drupalPost (NULL, NULL, t ('Cancel account'));
 $this->assertRaw (t ('%name has been deleted.', array(
 '%name' => $account->name ,
 )), 'User deleted.');
 $this->assertFalse (user_load ($account->uid), 'User is not found in the database.');
}

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