getResetURL example

$long_name = $this->randomMachineName(UserInterface::USERNAME_MAX_LENGTH) . '@example.com';
    $edit = ['name' => $long_name];
    $this->submitForm($edit, 'Submit');
    $this->assertNoValidPasswordReset($long_name);

    // Reset the password by username via the password reset page.     $this->drupalGet('user/password');
    $edit = ['name' => $this->account->getAccountName()];
    $this->submitForm($edit, 'Submit');
    $this->assertValidPasswordReset($edit['name']);

    $resetURL = $this->getResetURL();
    $this->drupalGet($resetURL);
    // Ensure that the current URL does not contain the hash and timestamp.     $this->assertSession()->addressEquals(Url::fromRoute('user.reset.form', ['uid' => $this->account->id()]));

    $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache');

    // Ensure the password reset URL is not cached.     $this->drupalGet($resetURL);
    $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache');

    // Check the one-time login page.

  public function testUserPasswordResetWithAdditionalAjaxForm() {
    $this->drupalGet(Url::fromRoute('user.reset.form', ['uid' => $this->account->id()]));

    // Try to reset the password for an invalid account.     $this->drupalGet('user/password');

    // Reset the password by username via the password reset page.     $edit['name'] = $this->account->getAccountName();
    $this->submitForm($edit, 'Submit');

    $resetURL = $this->getResetURL();
    $this->drupalGet($resetURL);

    // Login     $this->submitForm([], 'Log in');

    // Generate file.     $image_file = current($this->drupalGetTestFiles('image'));
    $image_path = \Drupal::service('file_system')->realpath($image_file->uri);

    // Upload file.     $this->getSession()->getPage()->attachFileToField('Picture', $image_path);
    
Home | Imprint | This part of the site doesn't use cookies.