You are here

function UserDeleteTest::testUserRegistration in SimpleTest 6

File

tests/user_module.test, line 235

Class

UserDeleteTest

Code

function testUserRegistration() {

  /* We first allow every user to login instantly. */
  $this
    ->drupalVariableSet('user_register', 1);

  /* make sure the profile module is disabled to avoid conflicts */
  $this
    ->drupalModuleDisable('profile');
  $name = $this
    ->randomName();
  $pname = theme('placeholder', $name);
  $mail = "{$name}@example.com";
  $edit = array(
    'name' => $name,
    'mail' => $mail,
  );
  $this
    ->drupalPost('user/register', $edit, 'Create new account');
  $user_to_delete = user_load($edit);
  $uid = $user_to_delete->uid;
  $web_user = $this
    ->drupalCreateUserRolePerm(array(
    'administer users',
  ));
  $this
    ->drupalLoginUser($web_user);
  $this->_browser
    ->get(url('user/' . $uid . '/edit', array(
    'absolute' => TRUE,
  )));
  $this->_browser
    ->clickSubmit(t('Delete'));
  $this
    ->assertWantedRaw(t('Are you sure you want to delete the account %name?', array(
    '%name' => $name,
  )), 'Confirm title');
  $this
    ->assertText(t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'), 'Confirm text');
  $this->_browser
    ->clickSubmit(t('Delete'));
  $this
    ->assertWantedRaw(t('%name has been deleted.', array(
    '%name' => $name,
  )), 'User deleted');
  $this
    ->assertFalse(user_load($edit), 'User is not found in the database');
}