You are here

public function PasswordPolicyPasswordTabTestCase::testCustomRedirectPath in Password Policy 7

Test custom redirect path with %uid variable.

@todo Deduplicate code versus testPasswordTab().

File

contrib/password_tab/password_policy_password_tab.test, line 56
Web tests for Password policy password tab module.

Class

PasswordPolicyPasswordTabTestCase
Tests of password tab.

Code

public function testCustomRedirectPath() {

  // Log in.
  $user = $this
    ->drupalCreateUser(array(
    'administer password policies',
    'administer site configuration',
  ));
  $this
    ->drupalLogin($user);

  // Set custom redirect path.
  $redirect_path = 'user/%uid/edit';
  $edit = array(
    'password_policy_password_tab_redirect' => $redirect_path,
  );
  $this
    ->drupalPost('admin/config/people/password_policy/password_tab', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));

  // Check tab is working.
  $this
    ->drupalGet('user/' . $user->uid . '/password');

  // Attempt password change.
  $edit = array(
    'current_pass' => $user->pass_raw,
    'pass[pass1]' => $user->pass_raw . $user->pass_raw,
    'pass[pass2]' => $user->pass_raw . $user->pass_raw,
  );
  $this
    ->drupalPost('user/' . $user->uid . '/password', $edit, 'Save');
  $this
    ->assertText(t('Password has been changed.'));

  // Check that user was correctly redirected.
  $this
    ->assertUrl('user/' . $user->uid . '/edit');
}