From 821bf8ad7ac02327a6fa68e8db4171df4a1a740f Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Thu, 29 Feb 2024 00:34:58 +0000
Subject: [PATCH] Issue #3422493 by mondrake, smustgrave: Change UrlHelperTest
 data providers and helpers to static

(cherry picked from commit 2d9de3fd7baf193b0d2f6a992ee69bb3007ab72e)
---
 .../Tests/Component/Utility/UrlHelperTest.php | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index da578931b3ec..f79915f18c6f 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -51,7 +51,7 @@ public function testBuildQuery($query, $expected, $message) {
    *
    * @return array
    */
-  public function providerTestValidAbsoluteData() {
+  public static function providerTestValidAbsoluteData(): array {
     $urls = [
       'example.com',
       'www.example.com',
@@ -75,7 +75,7 @@ public function providerTestValidAbsoluteData() {
       '[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html',
     ];
 
-    return $this->dataEnhanceWithScheme($urls);
+    return self::dataEnhanceWithScheme($urls);
   }
 
   /**
@@ -89,7 +89,7 @@ public function providerTestValidAbsoluteData() {
    * @param string $scheme
    *   The scheme to test.
    */
-  public function testValidAbsolute($url, $scheme) {
+  public function testValidAbsolute(string $url, string $scheme): void {
     $test_url = $scheme . '://' . $url;
     $valid_url = UrlHelper::isValid($test_url, TRUE);
     $this->assertTrue($valid_url, $test_url . ' is a valid URL.');
@@ -100,13 +100,13 @@ public function testValidAbsolute($url, $scheme) {
    *
    * @return array
    */
-  public function providerTestInvalidAbsolute() {
+  public static function providerTestInvalidAbsolute(): array {
     $data = [
       '',
       'ex!ample.com',
       'ex%ample.com',
     ];
-    return $this->dataEnhanceWithScheme($data);
+    return self::dataEnhanceWithScheme($data);
   }
 
   /**
@@ -144,7 +144,7 @@ public function testUncompressInvalidString() {
    * @param string $scheme
    *   The scheme to test.
    */
-  public function testInvalidAbsolute($url, $scheme) {
+  public function testInvalidAbsolute(string $url, string $scheme): void {
     $test_url = $scheme . '://' . $url;
     $valid_url = UrlHelper::isValid($test_url, TRUE);
     $this->assertFalse($valid_url, $test_url . ' is NOT a valid URL.');
@@ -155,7 +155,7 @@ public function testInvalidAbsolute($url, $scheme) {
    *
    * @return array
    */
-  public function providerTestValidRelativeData() {
+  public static function providerTestValidRelativeData(): array {
     $data = [
       'paren(the)sis',
       'index.html#pagetop',
@@ -164,7 +164,7 @@ public function providerTestValidRelativeData() {
       'login.php?do=login&style=%23#pagetop',
     ];
 
-    return $this->dataEnhanceWithPrefix($data);
+    return self::dataEnhanceWithPrefix($data);
   }
 
   /**
@@ -178,7 +178,7 @@ public function providerTestValidRelativeData() {
    * @param string $prefix
    *   The prefix to test.
    */
-  public function testValidRelative($url, $prefix) {
+  public function testValidRelative(string $url, string $prefix): void {
     $test_url = $prefix . $url;
     $valid_url = UrlHelper::isValid($test_url);
     $this->assertTrue($valid_url, $test_url . ' is a valid URL.');
@@ -189,14 +189,14 @@ public function testValidRelative($url, $prefix) {
    *
    * @return array
    */
-  public function providerTestInvalidRelativeData() {
+  public static function providerTestInvalidRelativeData(): array {
     $data = [
       // cspell:disable-next-line
       'ex^mple',
       'example<>',
       'ex%ample',
     ];
-    return $this->dataEnhanceWithPrefix($data);
+    return self::dataEnhanceWithPrefix($data);
   }
 
   /**
@@ -210,7 +210,7 @@ public function providerTestInvalidRelativeData() {
    * @param string $prefix
    *   The prefix to test.
    */
-  public function testInvalidRelative($url, $prefix) {
+  public function testInvalidRelative(string $url, string $prefix): void {
     $test_url = $prefix . $url;
     $valid_url = UrlHelper::isValid($test_url);
     $this->assertFalse($valid_url, $test_url . ' is NOT a valid URL.');
@@ -553,7 +553,7 @@ public static function providerTestStripDangerousProtocols() {
    * @return array
    *   A list of provider data with schemes.
    */
-  protected function dataEnhanceWithScheme(array $urls) {
+  protected static function dataEnhanceWithScheme(array $urls): array {
     $url_schemes = ['http', 'https', 'ftp'];
     $data = [];
     foreach ($url_schemes as $scheme) {
@@ -573,7 +573,7 @@ protected function dataEnhanceWithScheme(array $urls) {
    * @return array
    *   A list of provider data with prefixes.
    */
-  protected function dataEnhanceWithPrefix(array $urls) {
+  protected static function dataEnhanceWithPrefix(array $urls): array {
     $prefixes = ['', '/'];
     $data = [];
     foreach ($prefixes as $prefix) {
-- 
GitLab