You are here

function LegalPasswordResetTestCase::testPasswordReset in Legal 7

Same name and namespace in other branches
  1. 7.2 legal.test \LegalPasswordResetTestCase::testPasswordReset()

Accept T&C to successfully create an account.

File

./legal.test, line 128
Tests for Legal module.

Class

LegalPasswordResetTestCase
Test registering as new user and creating an account.

Code

function testPasswordReset() {

  // Create a log in link for the user, and go to that URL.
  // Borrowed from testUserPasswordResetExpired().
  $timestamp = REQUEST_TIME;
  $this
    ->drupalGet("user/reset/{$this->user->uid}/{$timestamp}/" . user_pass_rehash($this->user->pass, $timestamp, $this->user->login, $this->user->uid));
  $this
    ->assertText(t('Reset password'), "The reset password form is shown.");

  // Use the one-time login link.
  $this
    ->drupalPost(NULL, array(), t('Log in'));
  $this
    ->assertTitle(t('Terms and Conditions | Drupal'), "The user is redirected to the terms and conditions approval page.");
  $this
    ->assertText(t('Terms and Conditions'), "The Terms and Conditions form is shown.");

  // assertText() doesn't handle an '&' properly.
  $this
    ->assertText(t('To continue to use this site please read the Terms & Conditions below'), "The Terms and Conditions form is shown.");
  $edit = array(
    'legal_accept' => TRUE,
  );

  // Accept the T&Cs.
  $this
    ->drupalPost(NULL, $edit, t('Confirm'));
  $this
    ->assertText(t("You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password."), "The user is shown the message to reset their password.");
}