function LegalPasswordResetTestCase::testPasswordReset in Legal 7.2
Same name and namespace in other branches
- 7 legal.test \LegalPasswordResetTestCase::testPasswordReset()
Accept T&C to successfully create an account.
File
- ./
legal.test, line 131 - 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
->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'));
// Don't use assertUrl() as that requires us to match up the tokens in the
// query too.
$url = $this
->getUrl();
$path = parse_url($url, PHP_URL_PATH);
$expected_path = url("user/{$this->user->uid}/edit");
$this
->assertEqual($path, $expected_path, "The user is redirected to the user edit page.");
$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.");
}