Create an administrative user and delete another user.
function testUserCancelByAdmin() {
config('user.settings')
->set('cancel_method', 'user_cancel_reassign')
->save();
// 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.');
}