diff --git a/core/modules/user/tests/src/Functional/UserMailChangeTest.php b/core/modules/user/tests/src/Functional/UserMailChangeTest.php index b3bb9522a1..8cd7c1dd5a 100644 --- a/core/modules/user/tests/src/Functional/UserMailChangeTest.php +++ b/core/modules/user/tests/src/Functional/UserMailChangeTest.php @@ -48,6 +48,16 @@ protected function setUp() { public function testMailChange() { $this->drupalLogin($this->account); + // Ensure a time between the user last login and the time the account edit + // is posted. A human cannot login, edit the account and post the changes + // within the same second. But tests occasionally are running all steps in + // the same timestamp, so that the mail change URL timestamp equals the user + // last login timestamp. Later, in this test, when we try to reuse the + // expired link, we're still within the timestamp when the user last has + // logged in and we cannot experience a time difference as the user last + // login time has seconds as granularity. + sleep(1); + // Change the user email address. $new_mail = $this->getRandomEmailAddress(); $edit = [