From 5ccf44d2d9d2e6b867551652ddb907363d178a04 Mon Sep 17 00:00:00 2001
From: quietone <quietone@2572884.no-reply.drupal.org>
Date: Wed, 14 Feb 2024 15:40:16 +1300
Subject: [PATCH] Issue #3418236 by mstrelan, smustgrave: Fix strict type
 errors: Convert remaining usages of FormattableMarkup to strings in core
 Functional tests

---
 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php       | 3 +--
 .../tests/src/Functional/ContentTranslationUITestBase.php    | 3 +--
 .../system/tests/src/Functional/Form/CheckboxTest.php        | 3 +--
 core/modules/tour/tests/src/Functional/TourTestBase.php      | 3 +--
 .../views/tests/src/Functional/Handler/FieldWebTest.php      | 5 ++---
 5 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index 2e7083ff86f0..bdc11f51cbce 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -3,7 +3,6 @@
 namespace Drupal\Core\Test;
 
 use Drupal\Component\FileCache\FileCacheFactory;
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\Environment;
 use Drupal\Core\Config\Development\ConfigSchemaChecker;
 use Drupal\Core\Config\FileStorage;
@@ -474,7 +473,7 @@ protected function installModulesFromClassProperty(ContainerInterface $container
       $modules = array_unique($modules);
       try {
         $success = $container->get('module_installer')->install($modules, TRUE);
-        $this->assertTrue($success, new FormattableMarkup('Enabled modules: %modules', ['%modules' => implode(', ', $modules)]));
+        $this->assertTrue($success, 'Enabled modules: ' . implode(', ', $modules));
       }
       catch (MissingDependencyException $e) {
         // The exception message has all the details.
diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
index 689a006b9f3e..c2035dcb2fb6 100644
--- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\content_translation\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Entity\EntityChangedInterface;
 use Drupal\Core\Entity\EntityInterface;
@@ -576,7 +575,7 @@ protected function doTestTranslationChanged() {
         $entity = $storage->load($this->entityId);
         $this->assertEquals(
           $entity->getChangedTimeAcrossTranslations(), $entity->getTranslation($langcode)->getChangedTime(),
-          new FormattableMarkup('Changed time for language %language is the latest change over all languages.', ['%language' => $language->getName()])
+          "Changed time for language {$language->getName()} is the latest change over all languages."
         );
       }
 
diff --git a/core/modules/system/tests/src/Functional/Form/CheckboxTest.php b/core/modules/system/tests/src/Functional/Form/CheckboxTest.php
index 4e425343e2ba..5f78afdaa61c 100644
--- a/core/modules/system/tests/src/Functional/Form/CheckboxTest.php
+++ b/core/modules/system/tests/src/Functional/Form/CheckboxTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\system\Functional\Form;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -55,7 +54,7 @@ public function testFormCheckbox() {
           $checked = ($default_value === '1foobar');
         }
         $checked_in_html = str_contains($form, 'checked');
-        $message = new FormattableMarkup('#default_value is %default_value #return_value is %return_value.', ['%default_value' => var_export($default_value, TRUE), '%return_value' => var_export($return_value, TRUE)]);
+        $message = '#default_value is ' . var_export($default_value, TRUE) . ' #return_value is ' . var_export($return_value, TRUE) . '.';
         $this->assertSame($checked, $checked_in_html, $message);
       }
     }
diff --git a/core/modules/tour/tests/src/Functional/TourTestBase.php b/core/modules/tour/tests/src/Functional/TourTestBase.php
index 6fabf4c7ec2a..80ccd424dd1a 100644
--- a/core/modules/tour/tests/src/Functional/TourTestBase.php
+++ b/core/modules/tour/tests/src/Functional/TourTestBase.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\tour\Functional;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Tests\BrowserTestBase;
 
 /**
@@ -61,7 +60,7 @@ public function assertTourTips(array $tips = [], bool $expectEmpty = FALSE) {
     foreach ($tips as $tip) {
       if (!empty($tip['data-id'])) {
         $elements = $this->getSession()->getPage()->findAll('css', '#' . $tip['data-id']);
-        $this->assertCount(1, $elements, new FormattableMarkup('Found corresponding page element for tour tip with id #%data-id', ['%data-id' => $tip['data-id']]));
+        $this->assertCount(1, $elements, sprintf('Found corresponding page element for tour tip with id #%s', $tip['data-id']));
       }
       elseif (!empty($tip['data-class'])) {
         $elements = $this->getSession()->getPage()->findAll('css', '.' . $tip['data-class']);
diff --git a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
index fcd0e0ead927..032a78401139 100644
--- a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
+++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\views\Functional\Handler;
 
-use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Render\RenderContext;
@@ -637,10 +636,10 @@ public function testTextRendering() {
       });
 
       if ($tuple['trimmed']) {
-        $this->assertNotSubString($output, $tuple['value'], new FormattableMarkup('The untrimmed value (@untrimmed) should not appear in the trimmed output (@output).', ['@untrimmed' => $tuple['value'], '@output' => $output]));
+        $this->assertNotSubString($output, $tuple['value'], "The untrimmed value ({$tuple['value']}) should not appear in the trimmed output ($output).");
       }
       if (!empty($tuple['trimmed_value'])) {
-        $this->assertSubString($output, $tuple['trimmed_value'], new FormattableMarkup('The trimmed value (@trimmed) should appear in the trimmed output (@output).', ['@trimmed' => $tuple['trimmed_value'], '@output' => $output]));
+        $this->assertSubString($output, $tuple['trimmed_value'], "The trimmed value ({$tuple['trimmed_value']}) should appear in the trimmed output ($output).");
       }
     }
 
-- 
GitLab