From 2fa287c35fdc344e930d97e202464a37e21ce4dd Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 1 May 2024 17:42:39 +0100
Subject: [PATCH] Issue #3422383 by longwave, mondrake: Convert remaining data
 providers to static methods

(cherry picked from commit 96ab747a7cea370b803eb8d790b91d1fdefb049a)
---
 .../SettingsTrayBlockFormTest.php             |  6 +-
 .../SettingsTrayTestBase.php                  |  2 +-
 .../FunctionalJavascript/OffCanvasTest.php    |  2 +-
 .../OffCanvasTestBase.php                     |  6 +-
 ...ateSemverTestSecurityAvailabilityTrait.php |  2 +-
 .../Kernel/UpdateCalculateProjectDataTest.php |  2 +-
 .../Plugin/views/filter/NumericFilterTest.php |  2 +-
 .../Drupal/Tests/Core/Render/ElementTest.php  |  2 +-
 .../Drupal/Tests/Core/Render/RendererTest.php | 62 +++++++++----------
 .../Session/SuperUserAccessPolicyTest.php     |  4 +-
 .../Session/UserRolesAccessPolicyTest.php     |  2 +-
 .../tests/src/Unit/OliveroHexToHslTest.php    |  2 +-
 12 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
index 6741ab1294e0..68f29bb8de68 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
@@ -166,7 +166,7 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_
    */
   public function getBlockTests() {
     $blocks = [];
-    foreach ($this->getTestThemes() as $theme) {
+    foreach (static::getTestThemes() as $theme) {
       $blocks += [
         "$theme: block-powered" => [
           'theme' => $theme,
@@ -233,7 +233,7 @@ public function getBlockTests() {
    */
   public function testEditModeEnableDisable() {
     $this->markTestSkipped("Skipped due to frequent random test failures. See https://www.drupal.org/project/drupal/issues/3317520");
-    foreach ($this->getTestThemes() as $theme) {
+    foreach (static::getTestThemes() as $theme) {
       $this->enableTheme($theme);
       $block = $this->placeBlock('system_powered_by_block');
       foreach (['contextual_link', 'toolbar_link'] as $enable_option) {
@@ -270,7 +270,7 @@ public function testEditModeEnableDisable() {
   public function testValidationMessages() {
     $page = $this->getSession()->getPage();
     $web_assert = $this->assertSession();
-    foreach ($this->getTestThemes() as $theme) {
+    foreach (static::getTestThemes() as $theme) {
       $this->enableTheme($theme);
       $block = $this->placeBlock('settings_tray_test_validation');
       $this->drupalGet('user');
diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
index 8bd960e9f3e5..ae13a0fdf399 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
@@ -156,7 +156,7 @@ protected function assertOffCanvasBlockFormIsValid() {
   /**
    * {@inheritdoc}
    */
-  protected function getTestThemes() {
+  protected static function getTestThemes() {
     // Remove 'claro' theme. Settings Tray "Edit Mode" will not work with this
     // theme because it removes all contextual links.
     return array_filter(parent::getTestThemes(), function ($theme) {
diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
index 92c0c134f0cf..959b42bea4c5 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
@@ -125,7 +125,7 @@ public function testNarrowWidth() {
     $web_assert = $this->assertSession();
 
     // Test the same functionality on multiple themes.
-    foreach ($this->getTestThemes() as $theme) {
+    foreach (static::getTestThemes() as $theme) {
       $this->enableTheme($theme);
       // Testing at the wider width.
       $this->getSession()->resizeWindow($narrow_width_breakpoint + $offset, $height);
diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
index 6d3c900ff332..f09aaef10eb4 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
@@ -107,7 +107,7 @@ protected function getOffCanvasDialog() {
    * @return string[]
    *   Theme names to test.
    */
-  protected function getTestThemes() {
+  protected static function getTestThemes() {
     return ['claro', 'olivero', 'stable9', 'stark'];
   }
 
@@ -130,8 +130,8 @@ protected function assertElementVisibleAfterWait($selector, $locator, $timeout =
   /**
    * Data provider that returns theme name as the sole argument.
    */
-  public function themeDataProvider() {
-    $themes = $this->getTestThemes();
+  public static function themeDataProvider() {
+    $themes = static::getTestThemes();
     $data = [];
     foreach ($themes as $theme) {
       $data[$theme] = [
diff --git a/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php b/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php
index 8996accd87bf..e2f679d61c30 100644
--- a/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php
+++ b/core/modules/update/tests/src/Functional/UpdateSemverTestSecurityAvailabilityTrait.php
@@ -89,7 +89,7 @@ public function testSecurityUpdateAvailability($site_patch_version, array $expec
    *   - 8.0.1 Insecure
    *   - 8.0.0 Insecure
    */
-  public function securityUpdateAvailabilityProvider() {
+  public static function securityUpdateAvailabilityProvider() {
     $test_cases = [
       // Security release available for site minor release 0.
       // No releases for next minor.
diff --git a/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php b/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php
index e80dc469060e..e56b73c2d120 100644
--- a/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php
+++ b/core/modules/update/tests/src/Kernel/UpdateCalculateProjectDataTest.php
@@ -87,7 +87,7 @@ protected function setReleaseMetadata(string $file): void {
    * @return array[]
    *   Test data.
    */
-  public function providerProjectStatus(): array {
+  public static function providerProjectStatus(): array {
     return [
       'revoked' => [
         'fixture' => '/../../fixtures/release-history/drupal.project_status.revoked.0.2.xml',
diff --git a/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php b/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php
index 6752f9106580..f5bdf2b8c801 100644
--- a/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/views/filter/NumericFilterTest.php
@@ -44,7 +44,7 @@ public function testAcceptExposedInput($options, $value, $expected): void {
    * @return array[]
    *   The test cases.
    */
-  public function provideAcceptExposedInput(): array {
+  public static function provideAcceptExposedInput(): array {
     // [$options, $value, $expected]
     return [
       // Not exposed by default. Bypass parsing and return true.
diff --git a/core/tests/Drupal/Tests/Core/Render/ElementTest.php b/core/tests/Drupal/Tests/Core/Render/ElementTest.php
index eba2dd726845..709793dff076 100644
--- a/core/tests/Drupal/Tests/Core/Render/ElementTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/ElementTest.php
@@ -236,7 +236,7 @@ public function testIsRenderArray($build, $expected) {
     );
   }
 
-  public function dataProviderIsRenderArray() {
+  public static function dataProviderIsRenderArray() {
     return [
       'valid markup render array' => [['#markup' => 'hello world'], TRUE],
       'invalid "foo" string' => [['foo', '#markup' => 'hello world'], FALSE],
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
index 9ee5ba13c50e..552fbee231d6 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php
@@ -44,7 +44,7 @@ class RendererTest extends RendererTestBase {
   public function testRenderBasic($build, $expected, callable $setup_code = NULL) {
     if (isset($setup_code)) {
       $setup_code = $setup_code->bindTo($this);
-      $setup_code();
+      $setup_code($this->themeManager);
     }
 
     if (isset($build['#markup'])) {
@@ -63,7 +63,7 @@ public function testRenderBasic($build, $expected, callable $setup_code = NULL)
    *
    * @return array
    */
-  public function providerTestRenderBasic() {
+  public static function providerTestRenderBasic() {
     $data = [];
 
     // Part 1: the most simplistic render arrays possible, none using #theme.
@@ -266,10 +266,10 @@ function ($elements) {
       '#theme_wrappers' => ['container'],
       '#attributes' => ['class' => ['baz']],
     ];
-    $setup_code_type_link = function () {
-      $this->themeManager->expects($this->exactly(2))
+    $setup_code_type_link = function ($themeManager) {
+      $themeManager->expects(static::exactly(2))
         ->method('render')
-        ->with($this->logicalOr('common_test_foo', 'container'))
+        ->with(static::logicalOr('common_test_foo', 'container'))
         ->willReturnCallback(function ($theme, $vars) {
           if ($theme == 'container') {
             return '<div' . (string) (new Attribute($vars['#attributes'])) . '>' . $vars['#children'] . "</div>\n";
@@ -293,10 +293,10 @@ function ($elements) {
       '#url' => 'https://www.drupal.org',
       '#title' => 'bar',
     ];
-    $setup_code_type_link = function () {
-      $this->themeManager->expects($this->exactly(2))
+    $setup_code_type_link = function ($themeManager) {
+      $themeManager->expects(static::exactly(2))
         ->method('render')
-        ->with($this->logicalOr('link', 'container'))
+        ->with(static::logicalOr('link', 'container'))
         ->willReturnCallback(function ($theme, $vars) {
           if ($theme == 'container') {
             return '<div' . (string) (new Attribute($vars['#attributes'])) . '>' . $vars['#children'] . "</div>\n";
@@ -332,8 +332,8 @@ function ($elements) {
         'container',
       ],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->exactly(2))
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::exactly(2))
         ->method('render')
         ->with('container')
         ->willReturnCallback(function ($theme, $vars) {
@@ -347,8 +347,8 @@ function ($elements) {
       '#theme_wrappers' => [['container']],
       '#attributes' => ['class' => ['foo']],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->once())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::once())
         ->method('render')
         ->with(['container'])
         ->willReturnCallback(function ($theme, $vars) {
@@ -364,10 +364,10 @@ function ($elements) {
       '#theme' => ['suggestion_not_implemented'],
       '#markup' => 'foo',
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->once())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::once())
         ->method('render')
-        ->with(['suggestion_not_implemented'], $this->anything())
+        ->with(['suggestion_not_implemented'], static::anything())
         ->willReturn(FALSE);
     };
     $data[] = [$build, 'foo', $setup_code];
@@ -379,10 +379,10 @@ function ($elements) {
         '#markup' => 'foo',
       ],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->once())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::once())
         ->method('render')
-        ->with(['suggestion_not_implemented'], $this->anything())
+        ->with(['suggestion_not_implemented'], static::anything())
         ->willReturn(FALSE);
     };
     $data[] = [$build, 'foo', $setup_code];
@@ -392,11 +392,11 @@ function ($elements) {
       '#theme' => ['common_test_empty'],
       '#markup' => 'foo',
     ];
-    $theme_function_output = $this->randomContextValue();
-    $setup_code = function () use ($theme_function_output) {
-      $this->themeManager->expects($this->once())
+    $theme_function_output = static::randomContextValue();
+    $setup_code = function ($themeManager) use ($theme_function_output) {
+      $themeManager->expects(static::once())
         ->method('render')
-        ->with(['common_test_empty'], $this->anything())
+        ->with(['common_test_empty'], static::anything())
         ->willReturn($theme_function_output);
     };
     $data[] = [$build, $theme_function_output, $setup_code];
@@ -420,10 +420,10 @@ function ($elements) {
       '#children' => 'baz',
       'child' => ['#markup' => 'boo'],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->once())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::once())
         ->method('render')
-        ->with('common_test_foo', $this->anything())
+        ->with('common_test_foo', static::anything())
         ->willReturn('foobar');
     };
     $data[] = [$build, 'foobar', $setup_code];
@@ -439,8 +439,8 @@ function ($elements) {
         '#markup' => 'boo',
       ],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->never())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::never())
         ->method('render');
     };
     $data[] = [$build, 'boo', $setup_code];
@@ -455,8 +455,8 @@ function ($elements) {
         '#markup' => 'boo',
       ],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->never())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::never())
         ->method('render');
     };
     $data[] = [$build, 'baz', $setup_code];
@@ -474,8 +474,8 @@ function ($elements) {
         '#markup' => 'kitten',
       ],
     ];
-    $setup_code = function () {
-      $this->themeManager->expects($this->never())
+    $setup_code = function ($themeManager) {
+      $themeManager->expects(static::never())
         ->method('render');
     };
     $data[] = [$build, 'kitten', $setup_code];
diff --git a/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php b/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php
index 13b7feec432d..9abc270c75c1 100644
--- a/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php
@@ -86,7 +86,7 @@ public function testCalculatePermissions(int $uid, bool $expect_admin_rights): v
    * @return array
    *   A list of test scenarios.
    */
-  public function calculatePermissionsProvider(): array {
+  public static function calculatePermissionsProvider(): array {
     $cases['is-super-user'] = [1, TRUE];
     $cases['is-normal-user'] = [2, FALSE];
     return $cases;
@@ -122,7 +122,7 @@ public function testAlterPermissions(int $uid): void {
    * @return array
    *   A list of test scenarios.
    */
-  public function alterPermissionsProvider(): array {
+  public static function alterPermissionsProvider(): array {
     $cases['is-super-user'] = [1];
     $cases['is-normal-user'] = [2];
     return $cases;
diff --git a/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php b/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php
index a7fc00db10ea..36e141a410b2 100644
--- a/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php
@@ -124,7 +124,7 @@ public function testCalculatePermissions(array $roles, bool $expect_admin_rights
    * @return array
    *   A list of test scenarios.
    */
-  public function calculatePermissionsProvider(): array {
+  public static function calculatePermissionsProvider(): array {
     $cases['no-roles'] = [
       'roles' => [],
       'expect_admin_rights' => FALSE,
diff --git a/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php b/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php
index bf6b368907fe..ef3becb9e129 100644
--- a/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php
+++ b/core/themes/olivero/tests/src/Unit/OliveroHexToHslTest.php
@@ -41,7 +41,7 @@ public function testHexToHsl(string $hex, array $expected_hsl): void {
    * @return array[]
    *   The test data.
    */
-  public function hexCodes(): array {
+  public static function hexCodes(): array {
     return [
       'Blue Lagoon' => ['#1b9ae4', [202, 79, 50]],
       'Firehouse' => ['#a30f0f', [0, 83, 35]],
-- 
GitLab