1 user.test UserCancelTestCase::testUserCancelByAdmin()

Create an administrative user and delete another user.


core/modules/user/tests/user.test, line 886
Tests for user.module.


Test cancelling a user.


function testUserCancelByAdmin() {
  config_set('system.core', 'user_cancel_method', 'user_cancel_reassign');

  // Create a regular user.
  $account = $this->backdropCreateUser(array());

  // Create administrative user.
  $admin_user = $this->backdropCreateUser(array('administer users'));

  // Delete regular user.
  $this->backdropGet('user/' . $account->uid . '/edit');
  $this->backdropPost(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->backdropPost(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.');