You are here

protected function UserProtectPermissionsWebTest::testNoEditOwnPass in User protect 7

Tests edit password without permission "change own password".

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

File

tests/UserProtectPermissionsWebTest.test, line 145
Contains UserProtectPermissionsWebTest.

Class

UserProtectPermissionsWebTest
Tests permissions.

Code

protected function testNoEditOwnPass() {

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

  // Assert the password did not change.
  $account = user_load($account->uid, TRUE);
  $account->pass_raw = $expected_pass;
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($account);
}