diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
index 7583cb85cbc5b3ce8a450e826863e9c5fc492452..09a2cf47bc54a8d4721107c9f533ee1c7470f66b 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php
@@ -39,6 +39,14 @@ public function setUp() {
 
     $this->account = user_load($account->uid);
     $this->drupalLogout();
+
+    // Set the last login time that is used to generate the one-time link so
+    // that it is definitely over a second ago.
+    $account->login = REQUEST_TIME - mt_rand(10, 100000);
+    db_update('users')
+      ->fields(array('login' => $account->login))
+      ->condition('uid', $account->uid)
+      ->execute();
   }
 
   /**