You are here

protected function UserProtectPermissionsWebTest::testEditOwnPass in User protect 7

Tests edit password with permission "change own password".

Tests if an user with the permission "change own password" can edit its own password.

File

tests/UserProtectPermissionsWebTest.test, line 119
Contains UserProtectPermissionsWebTest.

Class

UserProtectPermissionsWebTest
Tests permissions.

Code

protected function testEditOwnPass() {

  // Create account that may edit its own password.
  $account = $this
    ->drupalCreateUser(array(
    'change own password',
    'edit own account',
  ));
  $this
    ->drupalLogin($account);
  $new_pass = $this
    ->randomName();
  $edit = array(
    'current_pass' => $account->pass_raw,
    'pass[pass1]' => $new_pass,
    'pass[pass2]' => $new_pass,
  );
  $this
    ->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save'));

  // Assert the password changed.
  $account = user_load($account->uid, TRUE);
  $account->pass_raw = $new_pass;
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($account);
}