From 2fdab0bde3283a5d8ba530fa56cf5a9fe73cb84c Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Thu, 23 Feb 2023 14:11:23 +0000
Subject: [PATCH] Issue #3308920 by jungle, smustgrave, Lendude: Fix test
 performance of Drupal\Tests\user\FunctionalJavascript\UserPasswordResetTest

(cherry picked from commit 1ac46a2af3149840fe9e6166aa87d4533843fd75)
---
 .../UserPasswordResetTest.php                 | 22 +++++++------------
 core/phpstan-baseline.neon                    |  5 -----
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php b/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php
index ee4e19b7a395..df8dbdc300b5 100644
--- a/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php
+++ b/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php
@@ -24,17 +24,6 @@ class UserPasswordResetTest extends WebDriverTestBase {
     getTestFiles as drupalGetTestFiles;
   }
 
-  /**
-   * The profile to install as a basis for testing.
-   *
-   * This test uses the standard profile to test the password reset in
-   * combination with an ajax request provided by the user picture configuration
-   * in the standard profile.
-   *
-   * @var string
-   */
-  protected $profile = 'standard';
-
   /**
    * The user object to test password resetting.
    *
@@ -45,7 +34,12 @@ class UserPasswordResetTest extends WebDriverTestBase {
   /**
    * {@inheritdoc}
    */
-  protected static $modules = ['block'];
+  protected static $modules = ['block', 'test_user_config'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stark';
 
   /**
    * {@inheritdoc}
@@ -54,7 +48,7 @@ protected function setUp(): void {
     parent::setUp();
 
     // Create a user.
-    $account = $this->drupalCreateUser();
+    $account = $this->drupalCreateUser(['access content']);
 
     // Activate user by logging in.
     $this->drupalLogin($account);
@@ -65,7 +59,7 @@ protected function setUp(): void {
 
     // 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);
+    $account->login = \Drupal::time()->getRequestTime() - mt_rand(10, 100000);
     Database::getConnection()->update('users_field_data')
       ->fields(['login' => $account->getLastLoginTime()])
       ->condition('uid', $account->id())
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 88b47ac34968..9071be711ad3 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -2490,11 +2490,6 @@ parameters:
 			count: 1
 			path: modules/user/tests/src/Functional/Views/UserChangedTest.php
 
-		-
-			message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
-			count: 1
-			path: modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php
-
 		-
 			message: "#^Variable \\$result in isset\\(\\) always exists and is not nullable\\.$#"
 			count: 1
-- 
GitLab