You are here

protected function UserProtectPermissionsWebTest::testNoEditOwnMail in User protect 7

Tests edit mail without permission "change own e-mail".

Tests if an user without the permission "change own e-mail" can not edit its own mail address.

File

tests/UserProtectPermissionsWebTest.test, line 97
Contains UserProtectPermissionsWebTest.

Class

UserProtectPermissionsWebTest
Tests permissions.

Code

protected function testNoEditOwnMail() {

  // Create account that may NOT edit its own mail address.
  $account = $this
    ->drupalCreateUser(array(
    'edit own account',
  ));
  $expected_mail = $account->mail;
  $this
    ->drupalLogin($account);
  $edit = array(
    'mail' => $this
      ->randomName() . '@example.com',
  );
  $this
    ->userprotectPostForm('user/' . $account->uid . '/edit', $edit, t('Save'));

  // Assert the mail address changed.
  $account = user_load($account->uid, TRUE);
  $this
    ->assertEqual($expected_mail, $account->mail, "The user's mail address was NOT changed.");
}