From 0fc32f077dc49bc994f3ee9af3d055d21746010d Mon Sep 17 00:00:00 2001
From: quietone <quietone@2572884.no-reply.drupal.org>
Date: Fri, 20 Dec 2024 13:33:32 +1300
Subject: [PATCH] Issue #3494633 by nikolay shapovalov, smustgrave: Remove
 FormattableMarkup from assertFileHookCalled()

---
 .../file/tests/src/Functional/FileManagedTestBase.php    | 7 +++----
 .../file/tests/src/Kernel/FileManagedUnitTestBase.php    | 9 ++++-----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/core/modules/file/tests/src/Functional/FileManagedTestBase.php b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
index f219a934b766..252a73822143 100644
--- a/core/modules/file/tests/src/Functional/FileManagedTestBase.php
+++ b/core/modules/file/tests/src/Functional/FileManagedTestBase.php
@@ -4,7 +4,6 @@
 
 namespace Drupal\Tests\file\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
 use Drupal\Tests\BrowserTestBase;
@@ -75,13 +74,13 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
-        $message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]);
+        $message = "hook_file_$hook was called correctly.";
       }
       elseif ($expected_count == 0) {
-        $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
+        $message = "hook_file_$hook was not expected to be called but was actually called $actual_count time(s).";
       }
       else {
-        $message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
+        $message = "hook_file_$hook was expected to be called $expected_count time(s) but was called $actual_count time(s).";
       }
     }
     $this->assertEquals($expected_count, $actual_count, $message);
diff --git a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
index 69fa3b41134f..96d9fbb06abd 100644
--- a/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
+++ b/core/modules/file/tests/src/Kernel/FileManagedUnitTestBase.php
@@ -4,7 +4,6 @@
 
 namespace Drupal\Tests\file\Kernel;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\file\Entity\File;
 use Drupal\file\FileInterface;
 use Drupal\KernelTests\KernelTestBase;
@@ -88,16 +87,16 @@ public function assertFileHookCalled($hook, $expected_count = 1, $message = NULL
 
     if (!isset($message)) {
       if ($actual_count == $expected_count) {
-        $message = new FormattableMarkup('hook_file_@name was called correctly.', ['@name' => $hook]);
+        $message = "hook_file_$hook was called correctly.";
       }
       elseif ($expected_count == 0) {
-        $message = \Drupal::translation()->formatPlural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', ['@name' => $hook, '@count' => $actual_count]);
+        $message = "hook_file_$hook was not expected to be called but was actually called $actual_count time(s).";
       }
       else {
-        $message = new FormattableMarkup('hook_file_@name was expected to be called %expected times but was called %actual times.', ['@name' => $hook, '%expected' => $expected_count, '%actual' => $actual_count]);
+        $message = "hook_file_$hook was expected to be called $expected_count time(s) but was called $actual_count time(s).";
       }
     }
-    $this->assertEquals($expected_count, $actual_count, (string) $message);
+    $this->assertEquals($expected_count, $actual_count, $message);
   }
 
   /**
-- 
GitLab