diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php
index 2eef791758a2739e4b57f3b6a70942bab5ce2b07..3a6b69dee68e0fbf74fdb68d5fde9be3aa1e41bd 100644
--- a/core/.phpstan-baseline.php
+++ b/core/.phpstan-baseline.php
@@ -19450,36 +19450,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php',
 ];
-$ignoreErrors[] = [
-	// identifier: missingType.return
-	'message' => '#^Function _file_test_log_call\\(\\) has no return type specified\\.$#',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/file/tests/file_test/file_test.module',
-];
-$ignoreErrors[] = [
-	// identifier: missingType.return
-	'message' => '#^Function file_test_file_scan_callback_reset\\(\\) has no return type specified\\.$#',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/file/tests/file_test/file_test.module',
-];
-$ignoreErrors[] = [
-	// identifier: missingType.return
-	'message' => '#^Function file_test_reset\\(\\) has no return type specified\\.$#',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/file/tests/file_test/file_test.module',
-];
-$ignoreErrors[] = [
-	// identifier: missingType.return
-	'message' => '#^Function file_test_set_return\\(\\) has no return type specified\\.$#',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/file/tests/file_test/file_test.module',
-];
-$ignoreErrors[] = [
-	// identifier: missingType.return
-	'message' => '#^Function file_test_validator\\(\\) has no return type specified\\.$#',
-	'count' => 1,
-	'path' => __DIR__ . '/modules/file/tests/file_test/file_test.module',
-];
 $ignoreErrors[] = [
 	// identifier: missingType.return
 	'message' => '#^Method Drupal\\\\file_test\\\\Form\\\\FileTestForm\\:\\:submitForm\\(\\) has no return type specified\\.$#',
diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module
deleted file mode 100644
index 4aa4116762c35322ff1bcca5600b40b124a2d9f1..0000000000000000000000000000000000000000
--- a/core/modules/file/tests/file_test/file_test.module
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-
-/**
- * @file
- * Helper module for the file tests.
- *
- * The caller is must call file_test_reset() to initializing this module before
- * calling file_test_get_calls() or file_test_set_return().
- */
-
-declare(strict_types=1);
-
-use Drupal\file\Entity\File;
-
-// cspell:ignore garply tarz
-
-const FILE_URL_TEST_CDN_1 = 'http://cdn1.example.com';
-const FILE_URL_TEST_CDN_2 = 'http://cdn2.example.com';
-
-/**
- * Reset/initialize the history of calls to the file_* hooks.
- *
- * @see file_test_get_calls()
- * @see file_test_reset()
- */
-function file_test_reset() {
-  // Keep track of calls to these hooks
-  $results = [
-    'load' => [],
-    'validate' => [],
-    'download' => [],
-    'insert' => [],
-    'update' => [],
-    'copy' => [],
-    'move' => [],
-    'delete' => [],
-  ];
-  \Drupal::state()->set('file_test.results', $results);
-
-  // These hooks will return these values, see file_test_set_return().
-  $return = [
-    'validate' => [],
-    'download' => NULL,
-  ];
-  \Drupal::state()->set('file_test.return', $return);
-}
-
-/**
- * Gets the arguments passed to a given hook invocation.
- *
- * Arguments are gathered since file_test_reset() was last called.
- *
- * @param string $op
- *   One of the hook_file_* operations: 'load', 'validate', 'download',
- *   'insert', 'update', 'copy', 'move', 'delete'.
- *
- * @return array
- *   Array of the parameters passed to each call.
- *
- * @see _file_test_log_call()
- * @see file_test_reset()
- */
-function file_test_get_calls($op) {
-  $results = \Drupal::state()->get('file_test.results', []);
-  return $results[$op];
-}
-
-/**
- * Get an array with the calls for all hooks.
- *
- * @return array
- *   An array keyed by hook name ('load', 'validate', 'download', 'insert',
- *   'update', 'copy', 'move', 'delete') with values being arrays of parameters
- *   passed to each call.
- */
-function file_test_get_all_calls() {
-  return \Drupal::state()->get('file_test.results', []);
-}
-
-/**
- * Store the values passed to a hook invocation.
- *
- * @param string $op
- *   One of the hook_file_* operations: 'load', 'validate', 'download',
- *   'insert', 'update', 'copy', 'move', 'delete'.
- * @param array $args
- *   Values passed to hook.
- *
- * @see file_test_get_calls()
- * @see file_test_reset()
- */
-function _file_test_log_call($op, $args) {
-  if (\Drupal::state()->get('file_test.count_hook_invocations', TRUE)) {
-    $results = \Drupal::state()->get('file_test.results', []);
-    $results[$op][] = $args;
-    \Drupal::state()->set('file_test.results', $results);
-  }
-}
-
-/**
- * Load the appropriate return value.
- *
- * @param string $op
- *   One of the hook_file_[validate,download] operations.
- *
- * @return mixed
- *   Value set by file_test_set_return().
- *
- * @see file_test_set_return()
- * @see file_test_reset()
- */
-function _file_test_get_return($op) {
-  $return = \Drupal::state()->get('file_test.return', [$op => NULL]);
-  return $return[$op];
-}
-
-/**
- * Assign a return value for a given operation.
- *
- * @param string $op
- *   One of the hook_file_[validate,download] operations.
- * @param mixed $value
- *   Value for the hook to return.
- *
- * @see _file_test_get_return()
- * @see file_test_reset()
- */
-function file_test_set_return($op, $value) {
-  $return = \Drupal::state()->get('file_test.return', []);
-  $return[$op] = $value;
-  \Drupal::state()->set('file_test.return', $return);
-}
-
-/**
- * Helper validator that returns the $errors parameter.
- */
-function file_test_validator(File $file, $errors) {
-  return $errors;
-}
-
-/**
- * Helper function for testing FileSystemInterface::scanDirectory().
- *
- * Each time the function is called the file is stored in a static variable.
- * When the function is called with no $filepath parameter, the results are
- * returned.
- *
- * @param string|null $filepath
- *   File path
- * @param bool $reset
- *   (optional) If to reset the internal memory cache. If TRUE is passed, the
- *   first parameter has no effect. Defaults to FALSE.
- *
- * @return array
- *   If $filepath is NULL, an array of all previous $filepath parameters
- */
-function file_test_file_scan_callback($filepath = NULL, $reset = FALSE) {
-  static $files = [];
-
-  if ($reset) {
-    $files = [];
-  }
-  elseif ($filepath) {
-    $files[] = $filepath;
-  }
-
-  return $files;
-}
-
-/**
- * Reset static variables used by file_test_file_scan_callback().
- */
-function file_test_file_scan_callback_reset() {
-  file_test_file_scan_callback(NULL, TRUE);
-}
diff --git a/core/modules/file/tests/file_test/src/FileTestCdn.php b/core/modules/file/tests/file_test/src/FileTestCdn.php
new file mode 100644
index 0000000000000000000000000000000000000000..b3796f6f74c851466cd0612610a39213754bf714
--- /dev/null
+++ b/core/modules/file/tests/file_test/src/FileTestCdn.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\file_test;
+
+/**
+ * Test Cdn.
+ */
+enum FileTestCdn: string {
+
+  /**
+   * First Cdn.
+   */
+  case First = 'http://cdn1.example.com';
+
+  /**
+   * Second Cdn.
+   */
+  case Second = 'http://cdn2.example.com';
+
+}
diff --git a/core/modules/file/tests/file_test/src/FileTestHelper.php b/core/modules/file/tests/file_test/src/FileTestHelper.php
new file mode 100644
index 0000000000000000000000000000000000000000..9ac3fbdf64190919bdae4ae5a3be84374afe7309
--- /dev/null
+++ b/core/modules/file/tests/file_test/src/FileTestHelper.php
@@ -0,0 +1,148 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\file_test;
+
+/**
+ * Helper for file tests.
+ *
+ * The caller must call reset() to initialize this module before
+ * calling Drupal\file_test\FileTestHelper::getCalls() or setReturn().
+ */
+class FileTestHelper {
+
+  /**
+   * Reset/initialize the history of calls to the file_* hooks.
+   *
+   * @see Drupal\file_test\FileTestHelper::getCalls()
+   * @see Drupal\file_test\FileTestHelper::reset()
+   */
+  public static function reset(): void {
+    // Keep track of calls to these hooks
+    $results = [
+      'load' => [],
+      'validate' => [],
+      'download' => [],
+      'insert' => [],
+      'update' => [],
+      'copy' => [],
+      'move' => [],
+      'delete' => [],
+    ];
+    \Drupal::state()->set('file_test.results', $results);
+
+    // These hooks will return these values, see FileTestHelper::setReturn().
+    $return = [
+      'validate' => [],
+      'download' => NULL,
+    ];
+    \Drupal::state()->set('file_test.return', $return);
+  }
+
+  /**
+   * Gets the arguments passed to a given hook invocation.
+   *
+   * Arguments are gathered since Drupal\file_test\FileTestHelper::reset() was last called.
+   *
+   * @param string $op
+   *   One of the hook_file_* operations: 'load', 'validate', 'download',
+   *   'insert', 'update', 'copy', 'move', 'delete'.
+   *
+   * @return array
+   *   Array of the parameters passed to each call.
+   *
+   * @see Drupal\file_test\FileTestHelper::logCall()
+   * @see Drupal\file_test\FileTestHelper::reset()
+   */
+  public static function getCalls($op): array {
+    $results = \Drupal::state()->get('file_test.results', []);
+    return $results[$op];
+  }
+
+  /**
+   * Get an array with the calls for all hooks.
+   *
+   * @return array
+   *   An array keyed by hook name ('load', 'validate', 'download', 'insert',
+   *   'update', 'copy', 'move', 'delete') with values being arrays of parameters
+   *   passed to each call.
+   */
+  public static function getAllCalls(): array {
+    return \Drupal::state()->get('file_test.results', []);
+  }
+
+  /**
+   * Store the values passed to a hook invocation.
+   *
+   * @param string $op
+   *   One of the hook_file_* operations: 'load', 'validate', 'download',
+   *   'insert', 'update', 'copy', 'move', 'delete'.
+   * @param array $args
+   *   Values passed to hook.
+   *
+   * @see Drupal\file_test\FileTestHelper::getCalls()
+   * @see Drupal\file_test\FileTestHelper::reset()
+   */
+  public static function logCall($op, $args): void {
+    if (\Drupal::state()->get('file_test.count_hook_invocations', TRUE)) {
+      $results = \Drupal::state()->get('file_test.results', []);
+      $results[$op][] = $args;
+      \Drupal::state()->set('file_test.results', $results);
+    }
+  }
+
+  /**
+   * Assign a return value for a given operation.
+   *
+   * @param string $op
+   *   One of the hook_file_[validate,download] operations.
+   * @param mixed $value
+   *   Value for the hook to return.
+   *
+   * @see Drupal\file_test\FileTestHelper::getReturn()
+   * @see Drupal\file_test\FileTestHelper::reset()
+   */
+  public static function setReturn($op, $value): void {
+    $return = \Drupal::state()->get('file_test.return', []);
+    $return[$op] = $value;
+    \Drupal::state()->set('file_test.return', $return);
+  }
+
+  /**
+   * Helper function for testing FileSystemInterface::scanDirectory().
+   *
+   * Each time the function is called the file is stored in a static variable.
+   * When the function is called with no $filepath parameter, the results are
+   * returned.
+   *
+   * @param string|null $filepath
+   *   File path
+   * @param bool $reset
+   *   (optional) If to reset the internal memory cache. If TRUE is passed, the
+   *   first parameter has no effect. Defaults to FALSE.
+   *
+   * @return array
+   *   If $filepath is NULL, an array of all previous $filepath parameters
+   */
+  public static function fileScanCallback($filepath = NULL, $reset = FALSE): array {
+    static $files = [];
+
+    if ($reset) {
+      $files = [];
+    }
+    elseif ($filepath) {
+      $files[] = $filepath;
+    }
+
+    return $files;
+  }
+
+  /**
+   * Reset static variables used by FileTestHelper::fileScanCallback().
+   */
+  public static function fileScanCallbackReset(): void {
+    self::fileScanCallback(NULL, TRUE);
+  }
+
+}
diff --git a/core/modules/file/tests/file_test/src/Hook/FileTestHooks.php b/core/modules/file/tests/file_test/src/Hook/FileTestHooks.php
index ba8b0ff84072644a903c7acee22772983329d402..1c300531f8d075cf294113c52d447ed32d65b68e 100644
--- a/core/modules/file/tests/file_test/src/Hook/FileTestHooks.php
+++ b/core/modules/file/tests/file_test/src/Hook/FileTestHooks.php
@@ -5,6 +5,8 @@
 namespace Drupal\file_test\Hook;
 
 use Drupal\file\Entity\File;
+use Drupal\file_test\FileTestCdn;
+use Drupal\file_test\FileTestHelper;
 use Drupal\Core\Hook\Attribute\Hook;
 
 // cspell:ignore tarz
@@ -21,7 +23,7 @@ class FileTestHooks {
   #[Hook('file_load')]
   public function fileLoad($files) {
     foreach ($files as $file) {
-      _file_test_log_call('load', [$file->id()]);
+      FileTestHelper::logCall('load', [$file->id()]);
       // Assign a value on the object so that we can test that the $file is passed
       // by reference.
       $file->file_test['loaded'] = TRUE;
@@ -38,8 +40,8 @@ public function fileDownload($uri) {
       $file = reset($files);
       return file_get_content_headers($file);
     }
-    _file_test_log_call('download', [$uri]);
-    return _file_test_get_return('download');
+    FileTestHelper::logCall('download', [$uri]);
+    return $this->getReturn('download');
   }
 
   /**
@@ -47,7 +49,7 @@ public function fileDownload($uri) {
    */
   #[Hook('file_insert')]
   public function fileInsert(File $file) {
-    _file_test_log_call('insert', [$file->id()]);
+    FileTestHelper::logCall('insert', [$file->id()]);
   }
 
   /**
@@ -55,7 +57,7 @@ public function fileInsert(File $file) {
    */
   #[Hook('file_update')]
   public function fileUpdate(File $file) {
-    _file_test_log_call('update', [$file->id()]);
+    FileTestHelper::logCall('update', [$file->id()]);
   }
 
   /**
@@ -63,7 +65,7 @@ public function fileUpdate(File $file) {
    */
   #[Hook('file_copy')]
   public function fileCopy(File $file, $source): void {
-    _file_test_log_call('copy', [$file->id(), $source->id()]);
+    FileTestHelper::logCall('copy', [$file->id(), $source->id()]);
   }
 
   /**
@@ -71,7 +73,7 @@ public function fileCopy(File $file, $source): void {
    */
   #[Hook('file_move')]
   public function fileMove(File $file, File $source): void {
-    _file_test_log_call('move', [$file->id(), $source->id()]);
+    FileTestHelper::logCall('move', [$file->id(), $source->id()]);
   }
 
   /**
@@ -79,7 +81,7 @@ public function fileMove(File $file, File $source): void {
    */
   #[Hook('file_predelete')]
   public function filePredelete(File $file) {
-    _file_test_log_call('delete', [$file->id()]);
+    FileTestHelper::logCall('delete', [$file->id()]);
   }
 
   /**
@@ -117,10 +119,10 @@ public function fileUrlAlter(&$uri): void {
         // CDN 2.
         $pathinfo = pathinfo($path);
         if (array_key_exists('extension', $pathinfo) && in_array($pathinfo['extension'], $cdn_extensions)) {
-          $uri = FILE_URL_TEST_CDN_1 . '/' . $path;
+          $uri = FileTestCdn::First->value . '/' . $path;
         }
         else {
-          $uri = FILE_URL_TEST_CDN_2 . '/' . $path;
+          $uri = FileTestCdn::Second->value . '/' . $path;
         }
       }
     }
@@ -197,4 +199,21 @@ public function entityTypeAlter(&$entity_types) : void {
     }
   }
 
+  /**
+   * Load the appropriate return value.
+   *
+   * @param string $op
+   *   One of the hook_file_[validate,download] operations.
+   *
+   * @return mixed
+   *   Value set by Drupal\file_test\FileTestHelper::setReturn().
+   *
+   * @see \Drupal\file_test\FileTestHelper::setReturn()
+   * @see Drupal\file_test\FileTestHelper::reset()
+   */
+  public function getReturn($op): mixed {
+    $return = \Drupal::state()->get('file_test.return', [$op => NULL]);
+    return $return[$op];
+  }
+
 }
diff --git a/core/modules/file/tests/modules/file_validator_test/src/EventSubscriber/FileValidationTestSubscriber.php b/core/modules/file/tests/modules/file_validator_test/src/EventSubscriber/FileValidationTestSubscriber.php
index 76a0c0d04c0f808f3a402f1078c9b07865f1b405..6bf927e8f61af93959c60df8bb65ecf43d2c4689 100644
--- a/core/modules/file/tests/modules/file_validator_test/src/EventSubscriber/FileValidationTestSubscriber.php
+++ b/core/modules/file/tests/modules/file_validator_test/src/EventSubscriber/FileValidationTestSubscriber.php
@@ -5,6 +5,7 @@
 namespace Drupal\file_validator_test\EventSubscriber;
 
 use Drupal\file\Validation\FileValidationEvent;
+use Drupal\file_test\FileTestHelper;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 
 /**
@@ -19,7 +20,7 @@ class FileValidationTestSubscriber implements EventSubscriberInterface {
    *   The event.
    */
   public function onFileValidation(FileValidationEvent $event): void {
-    _file_test_log_call('validate', [$event->file->id()]);
+    FileTestHelper::logCall('validate', [$event->file->id()]);
   }
 
   /**
diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php
index 8a34dc47178b50dba4b26a3e29848ba51f143f3d..83603f7508f856162f0d44eaa12fd0ab01109d21 100644
--- a/core/modules/file/tests/src/Functional/DownloadTest.php
+++ b/core/modules/file/tests/src/Functional/DownloadTest.php
@@ -6,6 +6,7 @@
 
 use Drupal\Core\Database\Database;
 use Drupal\Core\File\FileSystemInterface;
+use Drupal\file_test\FileTestHelper;
 
 /**
  * Tests for download/file transfer functions.
@@ -42,7 +43,7 @@ protected function setUp(): void {
 
     $this->fileUrlGenerator = $this->container->get('file_url_generator');
     // Clear out any hook calls.
-    file_test_reset();
+    FileTestHelper::reset();
   }
 
   /**
@@ -95,8 +96,8 @@ protected function doPrivateFileTransferTest(): void {
     $url = $this->fileUrlGenerator->generateAbsoluteString($file->getFileUri());
 
     // Set file_test access header to allow the download.
-    file_test_reset();
-    file_test_set_return('download', ['x-foo' => 'Bar']);
+    FileTestHelper::reset();
+    FileTestHelper::setReturn('download', ['x-foo' => 'Bar']);
     $this->drupalGet($url);
     // Verify that header is set by file_test module on private download.
     $this->assertSession()->responseHeaderEquals('x-foo', 'Bar');
@@ -111,7 +112,7 @@ protected function doPrivateFileTransferTest(): void {
     $http_client = $this->getHttpClient();
 
     // Try non-existent file.
-    file_test_reset();
+    FileTestHelper::reset();
     $not_found_url = $this->fileUrlGenerator->generateAbsoluteString('private://' . $this->randomMachineName() . '.txt');
     $response = $http_client->head($not_found_url, ['http_errors' => FALSE]);
     $this->assertSame(404, $response->getStatusCode(), 'Correctly returned 404 response for a non-existent file.');
@@ -121,8 +122,8 @@ protected function doPrivateFileTransferTest(): void {
     // Having tried a non-existent file, try the original file again to ensure
     // it's returned instead of a 404 response.
     // Set file_test access header to allow the download.
-    file_test_reset();
-    file_test_set_return('download', ['x-foo' => 'Bar']);
+    FileTestHelper::reset();
+    FileTestHelper::setReturn('download', ['x-foo' => 'Bar']);
     $this->drupalGet($url);
     // Verify that header is set by file_test module on private download.
     $this->assertSession()->responseHeaderEquals('x-foo', 'Bar');
@@ -133,12 +134,12 @@ protected function doPrivateFileTransferTest(): void {
     $this->assertSame($contents, $this->getSession()->getPage()->getContent(), 'Contents of the file are correct.');
 
     // Deny access to all downloads via a -1 header.
-    file_test_set_return('download', -1);
+    FileTestHelper::setReturn('download', -1);
     $response = $http_client->head($url, ['http_errors' => FALSE]);
     $this->assertSame(403, $response->getStatusCode(), 'Correctly denied access to a file when file_test sets the header to -1.');
 
     // Try requesting the private file URL without a file specified.
-    file_test_reset();
+    FileTestHelper::reset();
     $this->drupalGet('/system/files');
     $this->assertSession()->statusCodeEquals(404);
     // Assert that hook_file_download is not called.
@@ -211,7 +212,7 @@ private function checkUrl($scheme, $directory, $filename, $expected_url): void {
     if ($scheme == 'private') {
       // Tell the implementation of hook_file_download() in file_test.module
       // that this file may be downloaded.
-      file_test_set_return('download', ['x-foo' => 'Bar']);
+      FileTestHelper::setReturn('download', ['x-foo' => 'Bar']);
     }
 
     $this->drupalGet($url);
diff --git a/core/modules/file/tests/src/Functional/FileManagedTestBase.php b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
index 252a73822143025a0a8c1a18c2ff03a4af3813d1..e6755d3258d062a704ac4a3532c4c32c1995ff30 100644
--- a/core/modules/file/tests/src/Functional/FileManagedTestBase.php
+++ b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
@@ -6,6 +6,7 @@
 
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
+use Drupal\file_test\FileTestHelper;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -24,7 +25,7 @@ abstract class FileManagedTestBase extends BrowserTestBase {
   protected function setUp(): void {
     parent::setUp();
     // Clear out any hook calls.
-    file_test_reset();
+    FileTestHelper::reset();
   }
 
   /**
@@ -38,7 +39,7 @@ public function assertFileHooksCalled($expected) {
     \Drupal::state()->resetCache();
 
     // Determine which hooks were called.
-    $actual = array_keys(array_filter(file_test_get_all_calls()));
+    $actual = array_keys(array_filter(FileTestHelper::getAllCalls()));
 
     // Determine if there were any expected that were not called.
     $uncalled = array_diff($expected, $actual);
@@ -70,7 +71,7 @@ public function assertFileHooksCalled($expected) {
    *   Optional translated string message.
    */
   public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) {
-    $actual_count = count(file_test_get_calls($hook));
+    $actual_count = count(FileTestHelper::getCalls($hook));
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
index 6ec199d8651d40d9a7d3074561d39b502f7deccc..1b5da30af8e14a64b8938fb44fb5fb391149326d 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php
@@ -6,6 +6,7 @@
 
 use Drupal\Core\File\FileExists;
 use Drupal\file\Entity\File;
+use Drupal\file_test\FileTestHelper;
 use Drupal\Tests\TestFileCreationTrait;
 
 /**
@@ -96,7 +97,7 @@ protected function setUp(): void {
     // Check that the correct hooks were called then clean out the hook
     // counters.
     $this->assertFileHooksCalled(['validate', 'insert']);
-    file_test_reset();
+    FileTestHelper::reset();
   }
 
   /**
@@ -115,7 +116,7 @@ public function testNormal(): void {
     $this->assertEquals('image', substr($file1->getMimeType(), 0, 5), 'A MIME type was set.');
 
     // Reset the hook counters to get rid of the 'load' we just called.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Upload a second file.
     $image2 = current($this->drupalGetTestFiles('image'));
@@ -186,7 +187,7 @@ public function testHandleExtension(): void {
     $this->assertFileHooksCalled(['validate']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $extensions = 'foo ' . $this->imageExtension;
     // Now tell _file_save_upload_from_form() to allow the extension of our test image.
@@ -206,7 +207,7 @@ public function testHandleExtension(): void {
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Now tell _file_save_upload_from_form() to allow any extension.
     $edit = [
@@ -254,7 +255,7 @@ public function testHandleDangerousFile(): void {
     // Turn on insecure uploads.
     $config->set('allow_insecure_uploads', 1)->save();
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $this->drupalGet('file-test/save_upload_from_form_test');
     $this->submitForm($edit, 'Submit');
@@ -270,7 +271,7 @@ public function testHandleDangerousFile(): void {
     $config->set('allow_insecure_uploads', 0)->save();
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $edit = [
       'file_test_replace' => FileExists::Replace->name,
@@ -303,7 +304,7 @@ public function testHandleFileMunge(): void {
     $this->image = $file_repository->move($this->image, $original_uri . '.foo.' . $this->imageExtension);
 
     // Reset the hook counters to get rid of the 'move' we just called.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $extensions = $this->imageExtension;
     $edit = [
@@ -328,7 +329,7 @@ public function testHandleFileMunge(): void {
     // Test with uppercase extensions.
     $this->image = $file_repository->move($this->image, $original_uri . '.foo2.' . $this->imageExtension);
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
     $extensions = $this->imageExtension;
     $edit = [
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
@@ -351,7 +352,7 @@ public function testHandleFileMunge(): void {
 
     // Ensure we don't munge files if we're allowing any extension.
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Ensure we don't munge files if we're allowing any extension.
     $edit = [
@@ -372,7 +373,7 @@ public function testHandleFileMunge(): void {
     // Ensure that setting $validators['FileExtension'] = ['extensions' => NULL]
     // rejects all files.
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $edit = [
       'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php
index 6c5ea07a17b21839731eaff121be1f0309335841..66cfe08cad3830526ee4240ba442d2a99d7b9dfe 100644
--- a/core/modules/file/tests/src/Functional/SaveUploadTest.php
+++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php
@@ -8,6 +8,7 @@
 use Drupal\Core\File\FileExists;
 use Drupal\Core\Url;
 use Drupal\file\Entity\File;
+use Drupal\file_test\FileTestHelper;
 use Drupal\Tests\TestFileCreationTrait;
 
 // cSpell:ignore TÉXT Pácê
@@ -104,7 +105,7 @@ protected function setUp(): void {
     // Check that the correct hooks were called then clean out the hook
     // counters.
     $this->assertFileHooksCalled(['validate', 'insert']);
-    file_test_reset();
+    FileTestHelper::reset();
   }
 
   /**
@@ -123,7 +124,7 @@ public function testNormal(): void {
     $this->assertEquals('image', substr($file1->getMimeType(), 0, 5), 'A MIME type was set.');
 
     // Reset the hook counters to get rid of the 'load' we just called.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Upload a second file.
     $image2 = current($this->drupalGetTestFiles('image'));
@@ -226,7 +227,7 @@ public function testHandleExtension(): void {
     $this->assertFileHooksCalled(['validate']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $extensions = 'foo ' . $this->imageExtension;
     // Now tell file_save_upload() to allow the extension of our test image.
@@ -246,7 +247,7 @@ public function testHandleExtension(): void {
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Now tell file_save_upload() to allow any extension.
     $edit = [
@@ -264,7 +265,7 @@ public function testHandleExtension(): void {
     $this->assertFileHooksCalled(['validate', 'load', 'update']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Now tell file_save_upload() to allow any extension and try and upload a
     // malicious file.
@@ -314,7 +315,7 @@ public function testHandleDangerousFile(): void {
     // Turn on insecure uploads.
     $config->set('allow_insecure_uploads', 1)->save();
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $this->drupalGet('file-test/upload');
     $this->submitForm($edit, 'Submit');
@@ -327,7 +328,7 @@ public function testHandleDangerousFile(): void {
     $this->assertFileHooksCalled(['validate', 'insert']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Even with insecure uploads allowed, the .php file should not be uploaded
     // if it is not explicitly included in the list of allowed extensions.
@@ -342,7 +343,7 @@ public function testHandleDangerousFile(): void {
     $this->assertFileHooksCalled(['validate']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Turn off insecure uploads, then try the same thing as above (ensure that
     // the .php file is still rejected since it's not in the list of allowed
@@ -358,7 +359,7 @@ public function testHandleDangerousFile(): void {
     $this->assertFileHooksCalled(['validate']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     \Drupal::service('cache.config')->deleteAll();
 
@@ -417,7 +418,7 @@ public function testHandleDotFile(): void {
     $this->assertFileHooksCalled(['validate', 'insert']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Turn off insecure uploads, then try the same thing as above to ensure dot
     // files are renamed regardless.
@@ -433,7 +434,7 @@ public function testHandleDotFile(): void {
     $this->assertFileHooksCalled(['validate', 'insert']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
   }
 
   /**
@@ -448,7 +449,7 @@ public function testHandleFileMunge(): void {
     $this->image = $file_repository->move($this->image, $original_image_uri . '.foo.' . $this->imageExtension);
 
     // Reset the hook counters to get rid of the 'move' we just called.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $extensions = $this->imageExtension;
     $edit = [
@@ -471,7 +472,7 @@ public function testHandleFileMunge(): void {
     $this->assertFileHooksCalled(['validate', 'insert']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Ensure we don't munge the .foo extension if it is in the list of allowed
     // extensions.
@@ -494,7 +495,7 @@ public function testHandleFileMunge(): void {
     // Ensure we don't munge files if we're allowing any extension.
     $this->image = $file_repository->move($this->image, $original_image_uri . '.foo.txt.' . $this->imageExtension);
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $edit = [
       'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
@@ -515,7 +516,7 @@ public function testHandleFileMunge(): void {
     // the list of allowed extensions.
     $this->image = $file_repository->move($this->image, $original_image_uri . '.php.' . $this->imageExtension);
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $extensions = 'php ' . $this->imageExtension;
     $edit = [
@@ -534,7 +535,7 @@ public function testHandleFileMunge(): void {
     $this->assertFileHooksCalled(['validate', 'insert']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Dangerous extensions are munged even when all extensions are allowed.
     $edit = [
@@ -555,7 +556,7 @@ public function testHandleFileMunge(): void {
     // Dangerous extensions are munged if is renamed to end in .txt.
     $this->image = $file_repository->move($this->image, $original_image_uri . '.cgi.' . $this->imageExtension . '.txt');
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Dangerous extensions are munged even when all extensions are allowed.
     $edit = [
@@ -574,7 +575,7 @@ public function testHandleFileMunge(): void {
     $this->assertFileHooksCalled(['validate', 'insert']);
 
     // Reset the hook counters.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Ensure that setting $validators['FileExtension'] = ['extensions' = '']
     // rejects all files without munging or renaming.
@@ -748,7 +749,7 @@ public function testInvalidUtf8FilenameUpload(): void {
    */
   public function testRequired(): void {
     // Reset the hook counters to get rid of the 'load' we just called.
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Confirm the field is required.
     $this->drupalGet('file-test/upload_required');
diff --git a/core/modules/file/tests/src/Kernel/DeleteTest.php b/core/modules/file/tests/src/Kernel/DeleteTest.php
index e7e9a90a537abd15706cf5c33377d5f94b392c48..95139ef26f908724f5b8e28df8923943cd126359 100644
--- a/core/modules/file/tests/src/Kernel/DeleteTest.php
+++ b/core/modules/file/tests/src/Kernel/DeleteTest.php
@@ -6,6 +6,7 @@
 
 use Drupal\Core\Database\Database;
 use Drupal\file\Entity\File;
+use Drupal\file_test\FileTestHelper;
 
 /**
  * Tests the file delete function.
@@ -49,7 +50,7 @@ public function testInUse(): void {
     $this->assertNotEmpty(File::load($file->id()), 'File still exists in the database.');
 
     // Clear out the call to hook_file_load().
-    file_test_reset();
+    FileTestHelper::reset();
 
     $file_usage->delete($file, 'testing', 'test', 1);
     $usage = $file_usage->listUsage($file);
@@ -59,7 +60,7 @@ public function testInUse(): void {
     $file = File::load($file->id());
     $this->assertNotEmpty($file, 'File still exists in the database.');
     $this->assertTrue($file->isTemporary(), 'File is temporary.');
-    file_test_reset();
+    FileTestHelper::reset();
 
     // Call file_cron() to clean up the file. Make sure the changed timestamp
     // of the file is older than the system.file.temporary_maximum_age
diff --git a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
index 96d9fbb06abde2223f418deb52278452009730d7..4abecfade3a6850f306e082568a9d4be17aba443 100644
--- a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
+++ b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
@@ -6,6 +6,7 @@
 
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
+use Drupal\file_test\FileTestHelper;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\user\Entity\User;
 
@@ -25,7 +26,7 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
   protected function setUp(): void {
     parent::setUp();
     // Clear out any hook calls.
-    file_test_reset();
+    FileTestHelper::reset();
 
     $this->installConfig(['system']);
     $this->installEntitySchema('file');
@@ -51,7 +52,7 @@ public function assertFileHooksCalled($expected) {
     \Drupal::state()->resetCache();
 
     // Determine which hooks were called.
-    $actual = array_keys(array_filter(file_test_get_all_calls()));
+    $actual = array_keys(array_filter(FileTestHelper::getAllCalls()));
 
     // Determine if there were any expected that were not called.
     $uncalled = array_diff($expected, $actual);
@@ -83,7 +84,7 @@ public function assertFileHooksCalled($expected) {
    *   Optional translated string message.
    */
   public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) {
-    $actual_count = count(file_test_get_calls($hook));
+    $actual_count = count(FileTestHelper::getCalls($hook));
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
diff --git a/core/modules/file/tests/src/Kernel/LoadTest.php b/core/modules/file/tests/src/Kernel/LoadTest.php
index 38ab5a69a6f8edee26985b68ac30a27f4fb638b0..b5cf29430acb36ec8897f0e3589f5c288201c83a 100644
--- a/core/modules/file/tests/src/Kernel/LoadTest.php
+++ b/core/modules/file/tests/src/Kernel/LoadTest.php
@@ -6,6 +6,7 @@
 
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
+use Drupal\file_test\FileTestHelper;
 
 /**
  * Tests \Drupal\file\Entity\File::load().
@@ -65,7 +66,7 @@ public function testMultiple(): void {
     $file = $this->createFile('druplicon.txt', NULL, 'public');
 
     // Load by path.
-    file_test_reset();
+    FileTestHelper::reset();
     $by_path_files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['uri' => $file->getFileUri()]);
     $this->assertFileHookCalled('load');
     $this->assertCount(1, $by_path_files, '\Drupal::entityTypeManager()->getStorage(\'file\')->loadByProperties() returned an array of the correct size.');
@@ -74,7 +75,7 @@ public function testMultiple(): void {
     $this->assertEquals($file->id(), $by_path_file->id(), 'Loading by filepath got the correct fid.');
 
     // Load by fid.
-    file_test_reset();
+    FileTestHelper::reset();
     $by_fid_files = File::loadMultiple([$file->id()]);
     $this->assertFileHooksCalled([]);
     $this->assertCount(1, $by_fid_files, '\Drupal\file\Entity\File::loadMultiple() returned an array of the correct size.');
@@ -90,7 +91,7 @@ public function testUuidValues(): void {
     // Create a new file entity from scratch so we know the values.
     $file = $this->createFile('druplicon.txt', NULL, 'public');
     $file->save();
-    file_test_reset();
+    FileTestHelper::reset();
 
     $by_uuid_file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $file->uuid());
     $this->assertFileHookCalled('load');
diff --git a/core/modules/file/tests/src/Kernel/SaveTest.php b/core/modules/file/tests/src/Kernel/SaveTest.php
index 6de2071e05f20ea3fab91ac80a94c77194867071..9c85cbaec0119836f92d84cd34fdc1449ad682b4 100644
--- a/core/modules/file/tests/src/Kernel/SaveTest.php
+++ b/core/modules/file/tests/src/Kernel/SaveTest.php
@@ -5,6 +5,7 @@
 namespace Drupal\Tests\file\Kernel;
 
 use Drupal\file\Entity\File;
+use Drupal\file_test\FileTestHelper;
 use Drupal\Tests\user\Traits\UserCreationTrait;
 
 /**
@@ -45,7 +46,7 @@ public function testFileSave(): void {
     $this->assertEquals('en', $loaded_file->langcode->value, 'Langcode was defaulted correctly.');
 
     // Resave the file, updating the existing record.
-    file_test_reset();
+    FileTestHelper::reset();
     $file->status->value = 7;
     $file->save();
 
diff --git a/core/modules/file/tests/src/Kernel/Validation/FileValidatorTest.php b/core/modules/file/tests/src/Kernel/Validation/FileValidatorTest.php
index 4effd1ac0c5dba37be503f6a5f7283620649ee7f..e0b45e82c6627f9f0ebeb167312eaf57ebe72396 100644
--- a/core/modules/file/tests/src/Kernel/Validation/FileValidatorTest.php
+++ b/core/modules/file/tests/src/Kernel/Validation/FileValidatorTest.php
@@ -4,6 +4,8 @@
 
 namespace Drupal\Tests\file\Kernel\Validation;
 
+use Drupal\file_test\FileTestHelper;
+
 /**
  * Tests the file validator.
  *
@@ -32,25 +34,25 @@ public function testValidate(): void {
     $validators = [
       'FileNameLength' => [],
     ];
-    file_test_reset();
+    FileTestHelper::reset();
 
     $violations = $this->validator->validate($this->file, $validators);
     $this->assertCount(0, $violations);
-    $this->assertCount(1, file_test_get_calls('validate'));
+    $this->assertCount(1, FileTestHelper::getCalls('validate'));
 
-    file_test_reset();
+    FileTestHelper::reset();
     $this->file->set('filename', '');
     $violations = $this->validator->validate($this->file, $validators);
     $this->assertCount(1, $violations);
     $this->assertEquals($violations[0]->getMessage(), $violations[0]->getMessage(), 'Message names are equal');
-    $this->assertCount(1, file_test_get_calls('validate'));
+    $this->assertCount(1, FileTestHelper::getCalls('validate'));
 
-    file_test_reset();
+    FileTestHelper::reset();
     $this->file->set('filename', $this->randomMachineName(241));
     $violations = $this->validator->validate($this->file, $validators);
     $this->assertCount(1, $violations);
     $this->assertEquals("The file's name exceeds the 240 characters limit. Rename the file and try again.", $violations[0]->getMessage());
-    $this->assertCount(1, file_test_get_calls('validate'));
+    $this->assertCount(1, FileTestHelper::getCalls('validate'));
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php b/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php
index 8d9064a53050c866d9896f4ad21da72c4db2ffbf..f351699907de46848437640bcbb386cbdbd73cde 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php
@@ -5,6 +5,7 @@
 namespace Drupal\KernelTests\Core\File;
 
 use Drupal\Core\File\Exception\InvalidStreamWrapperException;
+use Drupal\file_test\FileTestCdn;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Session\Session;
 use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
@@ -79,10 +80,10 @@ public function testShippedFileURL(): void {
     \Drupal::state()->set('file_test.hook_file_url_alter', 'cdn');
     $filepath = 'core/assets/vendor/jquery/jquery.min.js';
     $url = $this->fileUrlGenerator->generateAbsoluteString($filepath);
-    $this->assertEquals(FILE_URL_TEST_CDN_1 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
+    $this->assertEquals(FileTestCdn::First->value . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
     $filepath = 'core/misc/favicon.ico';
     $url = $this->fileUrlGenerator->generateAbsoluteString($filepath);
-    $this->assertEquals(FILE_URL_TEST_CDN_2 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
+    $this->assertEquals(FileTestCdn::Second->value . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
 
     // Test alteration of file URLs to use root-relative URLs.
     \Drupal::state()->set('file_test.hook_file_url_alter', 'root-relative');
@@ -132,7 +133,7 @@ public function testPublicManagedFileURL(): void {
       ->getDirectoryPath();
     /** @var \Drupal\Core\File\FileSystemInterface $file_system */
     $file_system = \Drupal::service('file_system');
-    $this->assertEquals(FILE_URL_TEST_CDN_2 . '/' . $public_directory_path . '/' . $file_system->basename($uri), $url, 'Correctly generated a CDN URL for a created file.');
+    $this->assertEquals(FileTestCdn::Second->value . '/' . $public_directory_path . '/' . $file_system->basename($uri), $url, 'Correctly generated a CDN URL for a created file.');
 
     // Test alteration of file URLs to use root-relative URLs.
     \Drupal::state()->set('file_test.hook_file_url_alter', 'root-relative');
diff --git a/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
index d7dd425d30bd59f49b2bf2887fc79ff29cd3cd7f..7a8561ebfc43fb46a8ea4023dbe1cbe7cdfc7a59 100644
--- a/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php
@@ -4,6 +4,8 @@
 
 namespace Drupal\KernelTests\Core\File;
 
+use Drupal\file_test\FileTestHelper;
+
 /**
  * Tests \Drupal\Core\File\FileSystem::scanDirectory.
  *
@@ -78,18 +80,18 @@ public function testReturn(): void {
   public function testOptionCallback(): void {
 
     // When nothing is matched nothing should be passed to the callback.
-    $all_files = $this->fileSystem->scanDirectory($this->path, '/^NON-EXISTING-FILENAME/', ['callback' => 'file_test_file_scan_callback']);
+    $all_files = $this->fileSystem->scanDirectory($this->path, '/^NON-EXISTING-FILENAME/', ['callback' => '\Drupal\file_test\FileTestHelper::fileScanCallback']);
     $this->assertCount(0, $all_files, 'No files were found.');
-    $results = file_test_file_scan_callback();
-    file_test_file_scan_callback_reset();
+    $results = FileTestHelper::fileScanCallback();
+    FileTestHelper::fileScanCallbackReset();
     $this->assertCount(0, $results, 'No files were passed to the callback.');
 
     // Grab a listing of all the JavaScript files and check that they're
     // passed to the callback.
-    $all_files = $this->fileSystem->scanDirectory($this->path, '/^javascript-/', ['callback' => 'file_test_file_scan_callback']);
+    $all_files = $this->fileSystem->scanDirectory($this->path, '/^javascript-/', ['callback' => '\Drupal\file_test\FileTestHelper::fileScanCallback']);
     $this->assertCount(2, $all_files, 'Found two, expected javascript files.');
-    $results = file_test_file_scan_callback();
-    file_test_file_scan_callback_reset();
+    $results = FileTestHelper::fileScanCallback();
+    FileTestHelper::fileScanCallbackReset();
     $this->assertCount(2, $results, 'Files were passed to the callback.');
   }