From af369c3cce40404dbc75a9b04aef107b78d679cf Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Fri, 2 Feb 2024 07:57:36 +1000
Subject: [PATCH] Issue #3404508 by mstrelan, smustgrave, quietone: Fix strict
 type errors in Functional tests: Add casts and fix types where needed

---
 .../tests/src/Functional/BigPipeTest.php      | 40 ++++-----
 .../src/Functional/BookBreadcrumbTest.php     |  2 +-
 .../tests/src/Functional/BookTestTrait.php    |  2 +-
 .../src/Functional/CommentThreadingTest.php   | 10 +--
 .../src/Functional/ConfigEntityListTest.php   |  2 +-
 ...figInstallProfileUnmetDependenciesTest.php |  2 +-
 .../src/Functional/Number/NumberFieldTest.php |  2 +-
 .../src/Functional/ManageDisplayTest.php      |  2 +-
 .../Functional/FileOnTranslatedEntityTest.php |  2 +-
 .../PrivateFileOnTranslatedEntityTest.php     |  2 +-
 .../src/Functional/ImageDimensionsTest.php    |  2 +-
 .../src/Functional/ImageFieldDisplayTest.php  | 20 ++---
 .../tests/src/Functional/BlockContentTest.php |  2 +-
 .../EntityTestComputedFieldTest.php           |  2 +-
 .../src/Functional/EntityTestMapFieldTest.php |  2 +-
 .../tests/src/Functional/EntityTestTest.php   |  2 +-
 .../JsonApiFunctionalDateFieldTest.php        |  6 +-
 .../tests/src/Functional/MediaTest.php        |  2 +-
 .../src/Functional/MenuLinkContentTest.php    |  2 +-
 .../tests/src/Functional/ResourceTestBase.php |  4 +-
 .../jsonapi/tests/src/Functional/TermTest.php |  2 +-
 .../src/Functional/LocalePluralFormatTest.php |  2 +-
 .../ResponsiveImageFieldDisplayTest.php       |  4 +-
 .../src/Functional/ShortcutLinksTest.php      |  2 +-
 .../src/Functional/Form/CheckboxTest.php      |  2 +-
 .../System/SitesDirectoryHardeningTest.php    |  2 +-
 .../Functional/Theme/TwigDebugMarkupTest.php  |  8 +-
 .../tests/src/Functional/TrackerTest.php      | 14 ++--
 .../src/Functional/UserLoginHttpTest.php      | 10 +--
 .../Views/HandlerFieldUserNameTest.php        |  8 +-
 .../tests/src/Functional/Handler/AreaTest.php |  2 +-
 .../src/Functional/Handler/FieldWebTest.php   | 82 +++++++++----------
 .../Functional/Plugin/DisplayPageWebTest.php  |  8 +-
 .../src/Functional/Plugin/DisplayTest.php     | 22 ++---
 .../tests/src/Functional/Plugin/PagerTest.php |  2 +-
 35 files changed, 140 insertions(+), 140 deletions(-)

diff --git a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
index 0a5899ba9194..86a4ec44753e 100644
--- a/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
+++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
@@ -81,19 +81,19 @@ public function testNoJsDetection() {
 
     // 1. No session (anonymous).
     $this->drupalGet(Url::fromRoute('<front>'));
-    $this->assertSessionCookieExists(FALSE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('0');
+    $this->assertBigPipeNoJsCookieExists('0');
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
 
     // 2. Session (authenticated).
     $this->drupalLogin($this->rootUser);
-    $this->assertSessionCookieExists(TRUE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('1');
+    $this->assertBigPipeNoJsCookieExists('0');
     $this->assertSession()->responseContains('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . UrlHelper::encodePath(base_path() . 'user/1?check_logged_in=1') . '" />' . "\n" . '</noscript>');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
     $this->assertBigPipeNoJsMetaRefreshRedirect();
-    $this->assertBigPipeNoJsCookieExists(TRUE);
+    $this->assertBigPipeNoJsCookieExists('1');
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
     $this->assertSession()->responseContains($no_js_to_js_markup);
     $this->drupalLogout();
@@ -104,12 +104,12 @@ public function testNoJsDetection() {
     // 3. Session (anonymous).
     $this->drupalGet(Url::fromRoute('user.login', [], ['query' => ['trigger_session' => 1]]));
     $this->drupalGet(Url::fromRoute('user.login'));
-    $this->assertSessionCookieExists(TRUE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('1');
+    $this->assertBigPipeNoJsCookieExists('0');
     $this->assertSession()->responseContains('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . base_path() . 'user/login" />' . "\n" . '</noscript>');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
     $this->assertBigPipeNoJsMetaRefreshRedirect();
-    $this->assertBigPipeNoJsCookieExists(TRUE);
+    $this->assertBigPipeNoJsCookieExists('1');
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
     $this->assertSession()->responseContains($no_js_to_js_markup);
 
@@ -118,14 +118,14 @@ public function testNoJsDetection() {
 
     // Edge case: route with '_no_big_pipe' option.
     $this->drupalGet(Url::fromRoute('no_big_pipe'));
-    $this->assertSessionCookieExists(FALSE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('0');
+    $this->assertBigPipeNoJsCookieExists('0');
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
     $this->drupalLogin($this->rootUser);
     $this->drupalGet(Url::fromRoute('no_big_pipe'));
-    $this->assertSessionCookieExists(TRUE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('1');
+    $this->assertBigPipeNoJsCookieExists('0');
     $this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
     $this->assertSession()->responseNotContains($no_js_to_js_markup);
   }
@@ -145,8 +145,8 @@ public function testBigPipe() {
     $this->config('system.logging')->set('error_level', ERROR_REPORTING_HIDE)->save();
 
     $this->drupalLogin($this->rootUser);
-    $this->assertSessionCookieExists(TRUE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('1');
+    $this->assertBigPipeNoJsCookieExists('0');
 
     $connection = Database::getConnection();
     $log_count = $connection->select('watchdog')->countQuery()->execute()->fetchField();
@@ -236,8 +236,8 @@ public function testBigPipeNoJs() {
     $this->config('system.logging')->set('error_level', ERROR_REPORTING_HIDE)->save();
 
     $this->drupalLogin($this->rootUser);
-    $this->assertSessionCookieExists(TRUE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('1');
+    $this->assertBigPipeNoJsCookieExists('0');
 
     // By calling performMetaRefresh() here, we simulate JavaScript being
     // disabled, because as far as the BigPipe module is concerned, it is
@@ -245,7 +245,7 @@ public function testBigPipeNoJs() {
     // @see setUp()
     // @see performMetaRefresh()
     $this->performMetaRefresh();
-    $this->assertBigPipeNoJsCookieExists(TRUE);
+    $this->assertBigPipeNoJsCookieExists('1');
 
     $this->drupalGet(Url::fromRoute('big_pipe_test'));
     $this->assertBigPipeResponseHeadersPresent();
@@ -296,8 +296,8 @@ public function testBigPipeNoJs() {
    */
   public function testBigPipeMultiOccurrencePlaceholders() {
     $this->drupalLogin($this->rootUser);
-    $this->assertSessionCookieExists(TRUE);
-    $this->assertBigPipeNoJsCookieExists(FALSE);
+    $this->assertSessionCookieExists('1');
+    $this->assertBigPipeNoJsCookieExists('0');
 
     // By not calling performMetaRefresh() here, we simulate JavaScript being
     // enabled, because as far as the BigPipe module is concerned, JavaScript is
@@ -321,7 +321,7 @@ public function testBigPipeMultiOccurrencePlaceholders() {
     // @see setUp()
     // @see performMetaRefresh()
     $this->performMetaRefresh();
-    $this->assertBigPipeNoJsCookieExists(TRUE);
+    $this->assertBigPipeNoJsCookieExists('1');
     $this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence'));
     $this->assertSession()->pageTextContains('The count is 1.');
     $this->assertSession()->responseNotContains('The count is 2.');
diff --git a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
index 4652abd65150..a00acfa773be 100644
--- a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
+++ b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
@@ -117,7 +117,7 @@ protected function createBookNode($book_nid, $parent = NULL) {
     static $number = 0;
 
     $edit = [];
-    $edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - test node ' . $this->randomMachineName(10);
+    $edit['title[0][value]'] = str_pad((string) $number, 2, '0', STR_PAD_LEFT) . ' - test node ' . $this->randomMachineName(10);
     $edit['body[0][value]'] = 'test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
     $edit['book[bid]'] = $book_nid;
 
diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php
index fae697225f55..4488476f8bde 100644
--- a/core/modules/book/tests/src/Functional/BookTestTrait.php
+++ b/core/modules/book/tests/src/Functional/BookTestTrait.php
@@ -192,7 +192,7 @@ public function createBookNode($book_nid, $parent = NULL, $edit = []) {
     // Used to ensure that when sorted nodes stay in same order.
     static $number = 0;
 
-    $edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - test node ' . $this->randomMachineName(10);
+    $edit['title[0][value]'] = str_pad((string) $number, 2, '0', STR_PAD_LEFT) . ' - test node ' . $this->randomMachineName(10);
     $edit['body[0][value]'] = 'test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
     $edit['book[bid]'] = $book_nid;
 
diff --git a/core/modules/comment/tests/src/Functional/CommentThreadingTest.php b/core/modules/comment/tests/src/Functional/CommentThreadingTest.php
index 35f1d749d67e..08ced21dc42f 100644
--- a/core/modules/comment/tests/src/Functional/CommentThreadingTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentThreadingTest.php
@@ -125,14 +125,14 @@ public function testCommentThreading() {
   /**
    * Asserts that the link to the specified parent comment is present.
    *
-   * @param int $cid
+   * @param string $cid
    *   The comment ID to check.
-   * @param int $pid
+   * @param string $pid
    *   The expected parent comment ID.
    *
    * @internal
    */
-  protected function assertParentLink(int $cid, int $pid): void {
+  protected function assertParentLink(string $cid, string $pid): void {
     // This pattern matches a markup structure like:
     // @code
     // <article id="comment-2">
@@ -156,12 +156,12 @@ protected function assertParentLink(int $cid, int $pid): void {
   /**
    * Asserts that the specified comment does not have a link to a parent.
    *
-   * @param int $cid
+   * @param string $cid
    *   The comment ID to check.
    *
    * @internal
    */
-  protected function assertNoParentLink(int $cid): void {
+  protected function assertNoParentLink(string $cid): void {
     $pattern = "//article[@id='comment-$cid']";
     // A parent link is always accompanied by the text "In reply to".
     $this->assertSession()->elementTextNotContains('xpath', $pattern, 'In reply to');
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
index 05e4286cce29..428eab6c7b1f 100644
--- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php
@@ -322,7 +322,7 @@ public function testPager() {
     // Create 51 test entities.
     for ($i = 1; $i < 52; $i++) {
       $storage->create([
-        'id' => str_pad($i, 2, '0', STR_PAD_LEFT),
+        'id' => str_pad((string) $i, 2, '0', STR_PAD_LEFT),
         'label' => 'Test config entity ' . $i,
         'weight' => $i,
         'protected_property' => $i,
diff --git a/core/modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php b/core/modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php
index 5653b28e4e4c..dc5ace9423cc 100644
--- a/core/modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php
+++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php
@@ -80,7 +80,7 @@ protected function copyTestingOverrides() {
         mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
       }
       else {
-        copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
+        copy((string) $item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
       }
     }
 
diff --git a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
index 93030b0f9290..28e602741c43 100644
--- a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
+++ b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php
@@ -339,7 +339,7 @@ public function testNumberFloatField() {
     $this->assertSession()->responseContains('placeholder="0.00"');
 
     // Submit a signed decimal value within the allowed precision and scale.
-    $value = '-1234.5678';
+    $value = -1234.5678;
     $edit = [
       "{$field_name}[0][value]" => $value,
     ];
diff --git a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
index 6da294625c9e..d0f9b8a51fcc 100644
--- a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
+++ b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
@@ -108,7 +108,7 @@ public function testViewModeCustom() {
     // For this test, use a formatter setting value that is an integer unlikely
     // to appear in a rendered node other than as part of the field being tested
     // (for example, unlikely to be part of the "Submitted by ... on ..." line).
-    $value = 12345;
+    $value = '12345';
     $settings = [
       'type' => $this->type,
       'field_test' => [['value' => $value]],
diff --git a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
index 2ef77344f815..a533a90ec68d 100644
--- a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
+++ b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
@@ -72,7 +72,7 @@ protected function setUp(): void {
 
     // Enable translation for "Basic page" nodes.
     static::enableContentTranslation('node', 'page');
-    static::setFieldTranslatable('node', 'page', $this->fieldName, 1);
+    static::setFieldTranslatable('node', 'page', $this->fieldName, TRUE);
   }
 
   /**
diff --git a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php
index 3a3b1b04fb0a..47d666452009 100644
--- a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php
+++ b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php
@@ -64,7 +64,7 @@ protected function setUp(): void {
 
     // Enable translation for "Basic page" nodes.
     static::enableContentTranslation('node', 'page');
-    static::setFieldTranslatable('node', 'page', $this->fieldName, 1);
+    static::setFieldTranslatable('node', 'page', $this->fieldName, TRUE);
   }
 
   /**
diff --git a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
index 83f5dc39db48..fcfa3b8d7b7a 100644
--- a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
+++ b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php
@@ -304,7 +304,7 @@ public function testImageDimensions() {
    * altered and the element is re-rendered each time.
    */
   protected function getImageTag($variables) {
-    return str_replace("\n", '', \Drupal::service('renderer')->renderRoot($variables));
+    return str_replace("\n", '', (string) \Drupal::service('renderer')->renderRoot($variables));
   }
 
 }
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
index 8cef396210f5..14ccf54cc92d 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php
@@ -116,7 +116,7 @@ public function _testImageFieldFormatters($scheme) {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $default_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->assertSession()->responseContains($default_output);
 
     // Test the image linked to file formatter.
@@ -137,7 +137,7 @@ public function _testImageFieldFormatters($scheme) {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = '<a href="' . $file->createFileUrl() . '">' . $renderer->renderRoot($image) . '</a>';
+    $default_output = '<a href="' . $file->createFileUrl() . '">' . (string) $renderer->renderRoot($image) . '</a>';
     $this->drupalGet('node/' . $nid);
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]);
     // @todo Remove in https://www.drupal.org/node/2646744.
@@ -196,7 +196,7 @@ public function _testImageFieldFormatters($scheme) {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = $renderer->renderRoot($image_style);
+    $default_output = (string) $renderer->renderRoot($image_style);
     $this->drupalGet('node/' . $nid);
     $image_style = ImageStyle::load('thumbnail');
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $image_style->getCacheTags()[0]);
@@ -313,7 +313,7 @@ public function testImageFieldSettings() {
     ];
     $this->drupalGet('node/' . $nid . '/edit');
     $this->submitForm($edit, 'Save');
-    $default_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $default_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->assertSession()->responseContains($default_output);
 
     // Verify that alt/title longer than allowed results in a validation error.
@@ -421,7 +421,7 @@ public function testImageLoadingAttribute(): void {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $default_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->assertSession()->responseContains($default_output);
 
     // Test overrides of image loading attribute.
@@ -446,7 +446,7 @@ public function testImageLoadingAttribute(): void {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'eager'],
     ];
-    $default_output = $renderer->renderRoot($image);
+    $default_output = (string) $renderer->renderRoot($image);
     $this->drupalGet('node/' . $nid);
     $this->assertSession()->responseContains($default_output);
 
@@ -467,7 +467,7 @@ public function testImageLoadingAttribute(): void {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'eager'],
     ];
-    $default_output = $renderer->renderRoot($image_style);
+    $default_output = (string) $renderer->renderRoot($image_style);
     $this->drupalGet('node/' . $nid);
     $this->assertSession()->responseContains($default_output);
   }
@@ -521,7 +521,7 @@ public function testImageFieldDefaultImage() {
       '#height' => 20,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $default_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->drupalGet('node/' . $node->id());
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]);
     // Verify that no image style cache tags are found.
@@ -547,7 +547,7 @@ public function testImageFieldDefaultImage() {
       '#alt' => $alt,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $image_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $image_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->drupalGet('node/' . $nid);
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]);
     // Verify that no image style cache tags are found.
@@ -602,7 +602,7 @@ public function testImageFieldDefaultImage() {
       '#height' => 20,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $default_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->drupalGet('node/' . $node->id());
     $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', $file->getCacheTags()[0]);
     // Verify that no image style cache tags are found.
diff --git a/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php b/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
index dd964304d5cc..901bf7e1055a 100644
--- a/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
@@ -162,7 +162,7 @@ protected function getExpectedDocument() {
           ],
           'changed' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'info' => 'Llama',
-          'revision_created' => (new \DateTime())->setTimestamp($this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'revision_created' => (new \DateTime())->setTimestamp((int) $this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'revision_translation_affected' => TRUE,
           'status' => FALSE,
           'langcode' => 'en',
diff --git a/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php b/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php
index 36e1b4bf7d4a..e3f9a9838dd4 100644
--- a/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EntityTestComputedFieldTest.php
@@ -109,7 +109,7 @@ protected function getExpectedDocument() {
           'self' => ['href' => $self_url],
         ],
         'attributes' => [
-          'created' => (new \DateTime())->setTimestamp($this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'created' => (new \DateTime())->setTimestamp((int) $this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'name' => 'Llama',
           'drupal_internal__id' => 1,
           'computed_string_field' => NULL,
diff --git a/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php b/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php
index 8fa9fe4a5056..39fe99a21c3b 100644
--- a/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EntityTestMapFieldTest.php
@@ -110,7 +110,7 @@ protected function getExpectedDocument() {
           'self' => ['href' => $self_url],
         ],
         'attributes' => [
-          'created' => (new \DateTime())->setTimestamp($this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'created' => (new \DateTime())->setTimestamp((int) $this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'langcode' => 'en',
           'name' => 'Llama',
           'data' => static::$mapValue,
diff --git a/core/modules/jsonapi/tests/src/Functional/EntityTestTest.php b/core/modules/jsonapi/tests/src/Functional/EntityTestTest.php
index e4df38e31891..c63866c2372e 100644
--- a/core/modules/jsonapi/tests/src/Functional/EntityTestTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/EntityTestTest.php
@@ -121,7 +121,7 @@ protected function getExpectedDocument() {
           'self' => ['href' => $self_url],
         ],
         'attributes' => [
-          'created' => (new \DateTime())->setTimestamp($this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'created' => (new \DateTime())->setTimestamp((int) $this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'field_test_text' => NULL,
           'langcode' => 'en',
           'name' => 'Llama',
diff --git a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalDateFieldTest.php b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalDateFieldTest.php
index 21b2a7b9a39b..b38fa6c64f9e 100644
--- a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalDateFieldTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalDateFieldTest.php
@@ -57,9 +57,9 @@ public function testRead() {
     /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
     $date_formatter = $this->container->get('date.formatter');
 
-    $timestamp_1 = '5000000';
-    $timestamp_2 = '6000000';
-    $timestamp_3 = '7000000';
+    $timestamp_1 = 5000000;
+    $timestamp_2 = 6000000;
+    $timestamp_3 = 7000000;
     // Expected: node 1.
     $timestamp_smaller_than_value = $timestamp_2;
     // Expected: node 1 and node 2.
diff --git a/core/modules/jsonapi/tests/src/Functional/MediaTest.php b/core/modules/jsonapi/tests/src/Functional/MediaTest.php
index 84ad99b7da93..8bd69aff1363 100644
--- a/core/modules/jsonapi/tests/src/Functional/MediaTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/MediaTest.php
@@ -184,7 +184,7 @@ protected function getExpectedDocument() {
           'status' => TRUE,
           'created' => '1973-11-29T21:33:09+00:00',
           'changed' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
-          'revision_created' => (new \DateTime())->setTimestamp($this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'revision_created' => (new \DateTime())->setTimestamp((int) $this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'default_langcode' => TRUE,
           'revision_log_message' => NULL,
           // @todo Attempt to remove this in https://www.drupal.org/project/drupal/issues/2933518.
diff --git a/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php b/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php
index efc47df28b41..36b90c8f94b1 100644
--- a/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php
@@ -130,7 +130,7 @@ protected function getExpectedDocument() {
           'weight' => 0,
           'drupal_internal__id' => 1,
           'drupal_internal__revision_id' => 1,
-          'revision_created' => (new \DateTime())->setTimestamp($this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'revision_created' => (new \DateTime())->setTimestamp((int) $this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           'revision_log_message' => NULL,
           // @todo Attempt to remove this in https://www.drupal.org/project/drupal/issues/2933518.
           'revision_translation_affected' => TRUE,
diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
index be0c633adca7..8640f010e2a5 100644
--- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
+++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
@@ -2731,7 +2731,7 @@ protected function doTestIncluded(Url $url, array $request_options) {
       'all' => $relationship_field_names,
     ];
     if (count($relationship_field_names) > 1) {
-      $about_half_the_fields = floor(count($relationship_field_names) / 2);
+      $about_half_the_fields = (int) floor(count($relationship_field_names) / 2);
       $field_sets['some'] = array_slice($relationship_field_names, $about_half_the_fields);
 
       $nested_includes = $this->getNestedIncludePaths();
@@ -3324,7 +3324,7 @@ protected function getSparseFieldSets() {
     $field_names = array_keys($this->entity->toArray());
     $field_sets = [
       'empty' => [],
-      'some' => array_slice($field_names, floor(count($field_names) / 2)),
+      'some' => array_slice($field_names, (int) floor(count($field_names) / 2)),
       'all' => $field_names,
     ];
     if ($this->entity instanceof EntityOwnerInterface) {
diff --git a/core/modules/jsonapi/tests/src/Functional/TermTest.php b/core/modules/jsonapi/tests/src/Functional/TermTest.php
index 6cb401ba0f1d..5a56f19b1b2a 100644
--- a/core/modules/jsonapi/tests/src/Functional/TermTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/TermTest.php
@@ -281,7 +281,7 @@ protected function getExpectedDocument() {
           'drupal_internal__tid' => 1,
           'status' => TRUE,
           'drupal_internal__revision_id' => 1,
-          'revision_created' => (new \DateTime())->setTimestamp($this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+          'revision_created' => (new \DateTime())->setTimestamp((int) $this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
           // @todo Attempt to remove this in https://www.drupal.org/project/drupal/issues/2933518.
           'revision_translation_affected' => TRUE,
         ],
diff --git a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
index 27761996620b..6cfc2b344dd0 100644
--- a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
+++ b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php
@@ -144,7 +144,7 @@ public function testGetPluralFormat() {
         // Assert that the we get the right translation for that. Change the
         // expected index as per the logic for translation lookups.
         $expected_plural_index = ($count == 1) ? 0 : $expected_plural_index;
-        $expected_plural_string = str_replace('@count', $count, $plural_strings[$langcode][$expected_plural_index]);
+        $expected_plural_string = str_replace('@count', (string) $count, $plural_strings[$langcode][$expected_plural_index]);
         $this->assertSame($expected_plural_string, \Drupal::translation()->formatPlural($count, '@count hour', '@count hours', [], ['langcode' => $langcode])->render(), 'Plural translation of @count hour / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
         // DO NOT use translation to pass translated strings into
         // PluralTranslatableMarkup::createFromTranslatedString() this way. It
diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
index 6a2a42eff169..ccf3c9577ae0 100644
--- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
+++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php
@@ -213,7 +213,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
       '#alt' => $alt,
       '#attributes' => ['loading' => 'lazy'],
     ];
-    $default_output = str_replace("\n", '', $renderer->renderRoot($image));
+    $default_output = str_replace("\n", '', (string) $renderer->renderRoot($image));
     $this->assertSession()->responseContains($default_output);
 
     // Test field not being configured. This should not cause a fatal error.
@@ -341,7 +341,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
     // The image.html.twig template has a newline after the <img> tag but
     // responsive-image.html.twig doesn't have one after the fallback image, so
     // we remove it here.
-    $default_output = trim($renderer->renderRoot($fallback_image));
+    $default_output = trim((string) $renderer->renderRoot($fallback_image));
     $this->assertSession()->responseContains($default_output);
 
     if ($scheme == 'private') {
diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
index 9c8e9fd7d7eb..4838b4b4d51f 100644
--- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
+++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
@@ -465,7 +465,7 @@ public function testShortcutBlockAccess() {
    */
   protected function assertShortcutQuickLink(string $label, int $index = 0, string $message = ''): void {
     $links = $this->xpath('//a[normalize-space()=:label]', [':label' => $label]);
-    $message = ($message ? $message : new FormattableMarkup('Shortcut quick link with label %label found.', ['%label' => $label]));
+    $message = ($message ? $message : (string) new FormattableMarkup('Shortcut quick link with label %label found.', ['%label' => $label]));
     $this->assertArrayHasKey($index, $links, $message);
   }
 
diff --git a/core/modules/system/tests/src/Functional/Form/CheckboxTest.php b/core/modules/system/tests/src/Functional/Form/CheckboxTest.php
index 4e425343e2ba..a16190802d6a 100644
--- a/core/modules/system/tests/src/Functional/Form/CheckboxTest.php
+++ b/core/modules/system/tests/src/Functional/Form/CheckboxTest.php
@@ -35,7 +35,7 @@ public function testFormCheckbox() {
       // @see \Drupal\Core\Render\Element\Checkbox::processCheckbox().
       foreach (['0', '', 1, '1', 'foobar', '1foobar'] as $return_value) {
         $form_array = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestCheckboxTypeJugglingForm', $default_value, $return_value);
-        $form = \Drupal::service('renderer')->renderRoot($form_array);
+        $form = (string) \Drupal::service('renderer')->renderRoot($form_array);
         if ($default_value === TRUE) {
           $checked = TRUE;
         }
diff --git a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
index 112ad1266565..4bed0be43cc0 100644
--- a/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
+++ b/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
@@ -58,7 +58,7 @@ public function testSitesDirectoryHardeningConfig() {
     $requirements = $this->checkSystemRequirements();
     $this->assertEquals(REQUIREMENT_WARNING, $requirements['configuration_files']['severity'], 'Warning severity is properly set.');
     $this->assertEquals('Protection disabled', (string) $requirements['configuration_files']['value']);
-    $description = strip_tags(\Drupal::service('renderer')->renderPlain($requirements['configuration_files']['description']));
+    $description = strip_tags((string) \Drupal::service('renderer')->renderPlain($requirements['configuration_files']['description']));
     $this->assertStringContainsString('settings.php is not protected from modifications and poses a security risk.', $description);
     $this->assertStringContainsString('services.yml is not protected from modifications and poses a security risk.', $description);
 
diff --git a/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php b/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php
index 409a729aa4da..9e9dfd62aa7a 100644
--- a/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php
@@ -50,7 +50,7 @@ public function testTwigDebugMarkup() {
     $node = $this->drupalCreateNode();
     $builder = \Drupal::entityTypeManager()->getViewBuilder('node');
     $build = $builder->view($node);
-    $output = $renderer->renderRoot($build);
+    $output = (string) $renderer->renderRoot($build);
     $this->assertStringContainsString('<!-- THEME DEBUG -->', $output, 'Twig debug markup found in theme output when debug is enabled.');
     $this->assertStringContainsString("THEME HOOK: 'node'", $output, 'Theme call information found.');
     $this->assertStringContainsString('* node--1--full' . $extension . PHP_EOL . '   x node--1' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   * node' . $extension, $output, 'Suggested template files found in order and node ID specific template shown as current template.');
@@ -63,7 +63,7 @@ public function testTwigDebugMarkup() {
     // debug markup are correct.
     $node2 = $this->drupalCreateNode();
     $build = $builder->view($node2);
-    $output = $renderer->renderRoot($build);
+    $output = (string) $renderer->renderRoot($build);
     $this->assertStringContainsString('* node--2--full' . $extension . PHP_EOL . '   * node--2' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension, $output, 'Suggested template files found in order and base template shown as current template.');
 
     // Create another node and make sure the template suggestions shown in the
@@ -71,7 +71,7 @@ public function testTwigDebugMarkup() {
     $node3 = $this->drupalCreateNode();
     $build = ['#theme' => 'node__foo__bar'];
     $build += $builder->view($node3);
-    $output = $renderer->renderRoot($build);
+    $output = (string) $renderer->renderRoot($build);
     $this->assertStringContainsString("THEME HOOK: 'node__foo__bar'", $output, 'Theme call information found.');
     $this->assertStringContainsString('* node--foo--bar' . $extension . PHP_EOL . '   * node--foo' . $extension . PHP_EOL . '   * node--&lt;script type=&quot;text/javascript&quot;&gt;alert(&#039;yo&#039;);&lt;/script&gt;' . $extension . PHP_EOL . '   * node--3--full' . $extension . PHP_EOL . '   * node--3' . $extension . PHP_EOL . '   * node--page--full' . $extension . PHP_EOL . '   * node--page' . $extension . PHP_EOL . '   * node--full' . $extension . PHP_EOL . '   x node' . $extension, $output, 'Suggested template files found in order and base template shown as current template.');
 
@@ -83,7 +83,7 @@ public function testTwigDebugMarkup() {
     $this->resetAll();
 
     $build = $builder->view($node);
-    $output = $renderer->renderRoot($build);
+    $output = (string) $renderer->renderRoot($build);
     $this->assertStringNotContainsString('<!-- THEME DEBUG -->', $output, 'Twig debug markup not found in theme output when debug is disabled.');
   }
 
diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php
index 8c2f82af4aed..106c09f746f0 100644
--- a/core/modules/tracker/tests/src/Functional/TrackerTest.php
+++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php
@@ -269,19 +269,19 @@ public function testTrackerHistoryMetadata() {
 
     // Verify that the history metadata is updated.
     $this->drupalGet('activity');
-    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), $node->get('comment')->last_comment_timestamp);
+    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), (int) $node->get('comment')->last_comment_timestamp);
     $this->drupalGet('activity/' . $this->user->id());
-    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), $node->get('comment')->last_comment_timestamp);
+    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), (int) $node->get('comment')->last_comment_timestamp);
     $this->drupalGet('user/' . $this->user->id() . '/activity');
-    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), $node->get('comment')->last_comment_timestamp);
+    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), (int) $node->get('comment')->last_comment_timestamp);
 
     // Log out, now verify that the metadata is still there, but the library is
     // not.
     $this->drupalLogout();
     $this->drupalGet('activity');
-    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), $node->get('comment')->last_comment_timestamp, FALSE);
+    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), (int) $node->get('comment')->last_comment_timestamp, FALSE);
     $this->drupalGet('user/' . $this->user->id() . '/activity');
-    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), $node->get('comment')->last_comment_timestamp, FALSE);
+    $this->assertHistoryMetadata($node->id(), $node->getChangedTime(), (int) $node->get('comment')->last_comment_timestamp, FALSE);
   }
 
   /**
@@ -459,7 +459,7 @@ public function testTrackerAdminUnpublish() {
    * indicators, as well as the "x new" replies link to the tracker.
    * We do this in JavaScript to prevent breaking the render cache.
    *
-   * @param int $node_id
+   * @param string|int $node_id
    *   A node ID, that must exist as a data-history-node-id attribute
    * @param int $node_timestamp
    *   A node timestamp, that must exist as a data-history-node-timestamp
@@ -472,7 +472,7 @@ public function testTrackerAdminUnpublish() {
    *
    * @internal
    */
-  public function assertHistoryMetadata(int $node_id, int $node_timestamp, int $node_last_comment_timestamp, bool $library_is_present = TRUE): void {
+  public function assertHistoryMetadata(string|int $node_id, int $node_timestamp, int $node_last_comment_timestamp, bool $library_is_present = TRUE): void {
     $settings = $this->getDrupalSettings();
     $this->assertSame($library_is_present, isset($settings['ajaxPageState']) && in_array('tracker/history', explode(',', $settings['ajaxPageState']['libraries'])), 'drupal.tracker-history library is present.');
     $this->assertSession()->elementsCount('xpath', '//table/tbody/tr/td[@data-history-node-id="' . $node_id . '" and @data-history-node-timestamp="' . $node_timestamp . '"]', 1);
diff --git a/core/modules/user/tests/src/Functional/UserLoginHttpTest.php b/core/modules/user/tests/src/Functional/UserLoginHttpTest.php
index 3e018ae11c50..1ca3f4089593 100644
--- a/core/modules/user/tests/src/Functional/UserLoginHttpTest.php
+++ b/core/modules/user/tests/src/Functional/UserLoginHttpTest.php
@@ -183,7 +183,7 @@ protected function doTestLogin($format) {
 
     $response = $this->loginRequest($name, $pass, $format);
     $this->assertEquals(200, $response->getStatusCode());
-    $result_data = $this->serializer->decode($response->getBody(), $format);
+    $result_data = $this->serializer->decode((string) $response->getBody(), $format);
     $this->assertEquals($name, $result_data['current_user']['name']);
     $this->assertEquals($account->id(), $result_data['current_user']['uid']);
     $this->assertEquals($account->getRoles(), $result_data['current_user']['roles']);
@@ -192,7 +192,7 @@ protected function doTestLogin($format) {
     // Logging in while already logged in results in a 403 with helpful message.
     $response = $this->loginRequest($name, $pass, $format);
     $this->assertSame(403, $response->getStatusCode());
-    $this->assertSame(['message' => 'This route can only be accessed by anonymous users.'], $this->serializer->decode($response->getBody(), $format));
+    $this->assertSame(['message' => 'This route can only be accessed by anonymous users.'], $this->serializer->decode((string) $response->getBody(), $format));
 
     $response = $client->get($login_status_url, ['cookies' => $this->cookies]);
     $this->assertHttpResponse($response, 200, UserAuthenticationController::LOGGED_IN);
@@ -315,7 +315,7 @@ public function doTestGlobalLoginFloodControl(string $format): void {
 
     // IP limit has reached to its limit. Even valid user credentials will fail.
     $response = $this->loginRequest($user->getAccountName(), $user->passRaw, $format);
-    $this->assertHttpResponseWithMessage($response, '403', 'Access is blocked because of IP based flood prevention.', $format);
+    $this->assertHttpResponseWithMessage($response, 403, 'Access is blocked because of IP based flood prevention.', $format);
     $last_log = $database->select('watchdog', 'w')
       ->fields('w', ['message'])
       ->condition('type', 'user')
@@ -392,7 +392,7 @@ public function doTestPerUserLoginFloodControl($format): void {
 
       // A successful login will reset the per-user flood control count.
       $response = $this->loginRequest($user1->getAccountName(), $user1->passRaw, $format);
-      $result_data = $this->serializer->decode($response->getBody(), $format);
+      $result_data = $this->serializer->decode((string) $response->getBody(), $format);
       $this->logoutRequest($format, $result_data['logout_token']);
 
       // Try 3 failed logins for user 1, they will not trigger flood control.
@@ -475,7 +475,7 @@ public function doTestLogoutCsrfProtection(string $format): void {
 
     $response = $this->loginRequest($name, $pass, $format);
     $this->assertEquals(200, $response->getStatusCode());
-    $result_data = $this->serializer->decode($response->getBody(), $format);
+    $result_data = $this->serializer->decode((string) $response->getBody(), $format);
 
     $logout_token = $result_data['logout_token'];
 
diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php
index 62ce4a08d616..ff330bd53460 100644
--- a/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php
+++ b/core/modules/user/tests/src/Functional/Views/HandlerFieldUserNameTest.php
@@ -44,12 +44,12 @@ public function testUserName() {
     $anon_name = $this->config('user.settings')->get('anonymous');
     $view->result[0]->_entity->setUsername('');
     $view->result[0]->_entity->uid->value = 0;
-    $render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
+    $render = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
       return $view->field['name']->advancedRender($view->result[0]);
     });
     $this->assertStringContainsString($anon_name, $render, 'For user 0 it should use the default anonymous name by default.');
 
-    $render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $new_user) {
+    $render = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $new_user) {
       return $view->field['name']->advancedRender($view->result[$new_user->id()]);
     });
     $this->assertStringContainsString($new_user->getDisplayName(), $render, 'If link to user is checked the username should be part of the output.');
@@ -57,7 +57,7 @@ public function testUserName() {
 
     $view->field['name']->options['link_to_user'] = FALSE;
     $view->field['name']->options['type'] = 'string';
-    $render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $new_user) {
+    $render = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $new_user) {
       return $view->field['name']->advancedRender($view->result[$new_user->id()]);
     });
     $this->assertEquals($new_user->getDisplayName(), $render, 'If the user is not linked the username should be printed out for a normal user.');
@@ -77,7 +77,7 @@ public function testNoAdditionalFields() {
     $username = $this->randomMachineName();
     $view->result[0]->_entity->setUsername($username);
     $view->result[0]->_entity->uid->value = 1;
-    $render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
+    $render = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
       return $view->field['name']->advancedRender($view->result[0]);
     });
     $this->assertStringContainsString($username, $render, 'If link to user is checked the username should be part of the output.');
diff --git a/core/modules/views/tests/src/Functional/Handler/AreaTest.php b/core/modules/views/tests/src/Functional/Handler/AreaTest.php
index 62cdcee36ee0..9c4f6c2ffe4b 100644
--- a/core/modules/views/tests/src/Functional/Handler/AreaTest.php
+++ b/core/modules/views/tests/src/Functional/Handler/AreaTest.php
@@ -128,7 +128,7 @@ public function testRenderAreaToken() {
 
     // Test we have the site:name token in the output.
     $output = $view->preview();
-    $output = $this->container->get('renderer')->renderRoot($output);
+    $output = (string) $this->container->get('renderer')->renderRoot($output);
     $expected = \Drupal::token()->replace('[site:name]');
     $this->assertStringContainsString($expected, $output);
   }
diff --git a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
index fcd0e0ead927..658313026546 100644
--- a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
+++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php
@@ -235,7 +235,7 @@ public function testAlterUrl() {
     // Tests that the suffix/prefix appears on the output.
     $id_field->options['alter']['prefix'] = $prefix = $this->randomMachineName();
     $id_field->options['alter']['suffix'] = $suffix = $this->randomMachineName();
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, $prefix);
@@ -243,7 +243,7 @@ public function testAlterUrl() {
     unset($id_field->options['alter']['prefix']);
     unset($id_field->options['alter']['suffix']);
 
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, $path, 'Make sure that the path is part of the output');
@@ -256,28 +256,28 @@ public function testAlterUrl() {
 
       $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['absolute' => $absolute])->toString();
       $alter['absolute'] = $absolute;
-      $result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+      $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
         return $id_field->theme($row);
       });
       $this->assertSubString($result, $expected_result);
 
       $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['fragment' => 'foo', 'absolute' => $absolute])->toString();
       $alter['path'] = 'node/123#foo';
-      $result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+      $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
         return $id_field->theme($row);
       });
       $this->assertSubString($result, $expected_result);
 
       $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'absolute' => $absolute])->toString();
       $alter['path'] = 'node/123?foo';
-      $result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+      $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
         return $id_field->theme($row);
       });
       $this->assertSubString($result, $expected_result);
 
       $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => 'bar', 'bar' => 'baz'], 'absolute' => $absolute])->toString();
       $alter['path'] = 'node/123?foo=bar&bar=baz';
-      $result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+      $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
         return $id_field->theme($row);
       });
       $this->assertSubString(Html::decodeEntities($result), Html::decodeEntities($expected_result));
@@ -286,14 +286,14 @@ public function testAlterUrl() {
       // $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute])->toString();
       $expected_result = Url::fromUserInput('/node/123', ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute])->toString();
       $alter['path'] = 'node/123?foo#bar';
-      $result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+      $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
         return $id_field->theme($row);
       });
       $this->assertSubString(Html::decodeEntities($result), Html::decodeEntities($expected_result));
 
       $expected_result = Url::fromRoute('<front>', [], ['absolute' => $absolute])->toString();
       $alter['path'] = '<front>';
-      $result = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+      $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
         return $id_field->theme($row);
       });
       $this->assertSubString($result, $expected_result);
@@ -302,12 +302,12 @@ public function testAlterUrl() {
     // Tests the replace spaces with dashes feature.
     $id_field->options['alter']['replace_spaces'] = TRUE;
     $id_field->options['alter']['path'] = $path = $this->randomMachineName() . ' ' . $this->randomMachineName();
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, str_replace(' ', '-', $path));
     $id_field->options['alter']['replace_spaces'] = FALSE;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     // The URL has a space in it, so to check we have to decode the URL output.
@@ -317,7 +317,7 @@ public function testAlterUrl() {
     // Switch on the external flag should output an external URL as well.
     $id_field->options['alter']['external'] = TRUE;
     $id_field->options['alter']['path'] = $path = 'www.example.com';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, 'http://www.example.com');
@@ -325,7 +325,7 @@ public function testAlterUrl() {
     // Setup a not external URL, which shouldn't lead to an external URL.
     $id_field->options['alter']['external'] = FALSE;
     $id_field->options['alter']['path'] = $path = 'www.example.com';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertNotSubString($output, 'http://www.example.com');
@@ -333,19 +333,19 @@ public function testAlterUrl() {
     // Tests the transforming of the case setting.
     $id_field->options['alter']['path'] = $path = $this->randomMachineName();
     $id_field->options['alter']['path_case'] = 'none';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, $path);
 
     // Switch to uppercase and lowercase.
     $id_field->options['alter']['path_case'] = 'upper';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, strtoupper($path));
     $id_field->options['alter']['path_case'] = 'lower';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, strtolower($path));
@@ -353,13 +353,13 @@ public function testAlterUrl() {
     // Switch to ucfirst and ucwords.
     $id_field->options['alter']['path_case'] = 'ucfirst';
     $id_field->options['alter']['path'] = 'drupal has a great community';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, UrlHelper::encodePath('Drupal has a great community'));
 
     $id_field->options['alter']['path_case'] = 'ucwords';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $this->assertSubString($output, UrlHelper::encodePath('Drupal Has A Great Community'));
@@ -368,7 +368,7 @@ public function testAlterUrl() {
     // Tests the link_class setting and see whether it actually exists in the
     // output.
     $id_field->options['alter']['link_class'] = $class = $this->randomMachineName();
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $elements = $this->xpathContent($output, '//a[contains(@class, :class)]', [':class' => $class]);
@@ -378,7 +378,7 @@ public function testAlterUrl() {
 
     // Tests the alt setting.
     $id_field->options['alter']['alt'] = $rel = $this->randomMachineName();
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $elements = $this->xpathContent($output, '//a[contains(@title, :alt)]', [':alt' => $rel]);
@@ -387,7 +387,7 @@ public function testAlterUrl() {
 
     // Tests the rel setting.
     $id_field->options['alter']['rel'] = $rel = $this->randomMachineName();
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $elements = $this->xpathContent($output, '//a[contains(@rel, :rel)]', [':rel' => $rel]);
@@ -396,7 +396,7 @@ public function testAlterUrl() {
 
     // Tests the target setting.
     $id_field->options['alter']['target'] = $target = $this->randomMachineName();
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
       return $id_field->theme($row);
     });
     $elements = $this->xpathContent($output, '//a[contains(@target, :target)]', [':target' => $target]);
@@ -420,13 +420,13 @@ public function testFieldClasses() {
     // Setup some kind of label by default.
     $id_field->options['label'] = $this->randomMachineName();
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertEmpty($this->xpathContent($output, '//div[contains(@class, :class)]', [':class' => 'field-content']));
     $this->assertEmpty($this->xpathContent($output, '//div[contains(@class, :class)]', [':class' => 'field__label']));
 
     $id_field->options['element_default_classes'] = TRUE;
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     // Per default the label and the element of the field are spans.
     $this->assertNotEmpty($this->xpathContent($output, '//span[contains(@class, :class)]', [':class' => 'field-content']));
     $this->assertNotEmpty($this->xpathContent($output, '//span[contains(@class, :class)]', [':class' => 'views-label']));
@@ -442,13 +442,13 @@ public function testFieldClasses() {
       // Set a custom wrapper element css class.
       $id_field->options['element_wrapper_class'] = $random_class;
       $output = $view->preview();
-      $output = $renderer->renderRoot($output);
+      $output = (string) $renderer->renderRoot($output);
       $this->assertNotEmpty($this->xpathContent($output, "//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
 
       // Set no custom css class.
       $id_field->options['element_wrapper_class'] = '';
       $output = $view->preview();
-      $output = $renderer->renderRoot($output);
+      $output = (string) $renderer->renderRoot($output);
       $this->assertEmpty($this->xpathContent($output, "//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
       $this->assertNotEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]/{$element_type}"));
     }
@@ -462,13 +462,13 @@ public function testFieldClasses() {
       // Set a custom label element css class.
       $id_field->options['element_label_class'] = $random_class;
       $output = $view->preview();
-      $output = $renderer->renderRoot($output);
+      $output = (string) $renderer->renderRoot($output);
       $this->assertNotEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
 
       // Set no custom css class.
       $id_field->options['element_label_class'] = '';
       $output = $view->preview();
-      $output = $renderer->renderRoot($output);
+      $output = (string) $renderer->renderRoot($output);
       $this->assertEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
       $this->assertNotEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]//{$element_type}"));
     }
@@ -482,13 +482,13 @@ public function testFieldClasses() {
       // Set a custom label element css class.
       $id_field->options['element_class'] = $random_class;
       $output = $view->preview();
-      $output = $renderer->renderRoot($output);
+      $output = (string) $renderer->renderRoot($output);
       $this->assertNotEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
 
       // Set no custom css class.
       $id_field->options['element_class'] = '';
       $output = $view->preview();
-      $output = $renderer->renderRoot($output);
+      $output = (string) $renderer->renderRoot($output);
       $this->assertEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}[contains(@class, :class)]", [':class' => $random_class]));
       $this->assertNotEmpty($this->xpathContent($output, "//li[contains(@class, views-row)]//div[contains(@class, views-field)]//{$element_type}"));
     }
@@ -534,7 +534,7 @@ public function testTextRendering() {
     $row = $view->result[0];
 
     $name_field->options['alter']['strip_tags'] = TRUE;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $random_text, 'Find text without html if stripping of views field output is enabled.');
@@ -542,14 +542,14 @@ public function testTextRendering() {
 
     // Tests preserving of html tags.
     $name_field->options['alter']['preserve_tags'] = '<div>';
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $random_text, 'Find text without html if stripping of views field output is enabled but a div is allowed.');
     $this->assertSubString($output, $html_text, 'Find text with the html if stripping of views field output is enabled but a div is allowed.');
 
     $name_field->options['alter']['strip_tags'] = FALSE;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $random_text, 'Find text without html if stripping of views field output is disabled.');
@@ -560,7 +560,7 @@ public function testTextRendering() {
     $views_test_data_name = $row->views_test_data_name;
     $row->views_test_data_name = '  ' . $views_test_data_name . '     ';
     $name_field->options['alter']['trim_whitespace'] = TRUE;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
 
@@ -568,7 +568,7 @@ public function testTextRendering() {
     $this->assertNotSubString($output, $row->views_test_data_name, 'Make sure the untrimmed text can be found if trimming is enabled.');
 
     $name_field->options['alter']['trim_whitespace'] = FALSE;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $views_test_data_name, 'Make sure the trimmed text can be found if trimming is disabled.');
@@ -583,14 +583,14 @@ public function testTextRendering() {
     $name_field->options['alter']['max_length'] = 5;
     $trimmed_name = mb_substr($row->views_test_data_name, 0, 5);
 
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $trimmed_name, "Make sure the trimmed output ($trimmed_name) appears in the rendered output ($output).");
     $this->assertNotSubString($output, $row->views_test_data_name, "Make sure the untrimmed value ($row->views_test_data_name) shouldn't appear in the rendered output ($output).");
 
     $name_field->options['alter']['max_length'] = 9;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $trimmed_name, "Make sure the untrimmed ($trimmed_name) output appears in the rendered output  ($output).");
@@ -632,7 +632,7 @@ public function testTextRendering() {
 
     foreach ($tuples as $tuple) {
       $row->views_test_data_name = $tuple['value'];
-      $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+      $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
         return $name_field->advancedRender($row);
       });
 
@@ -651,14 +651,14 @@ public function testTextRendering() {
     $name_field->options['alter']['more_link_text'] = $more_text = $this->randomMachineName();
     $name_field->options['alter']['more_link_path'] = $more_path = $this->randomMachineName();
 
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, $more_text, 'Make sure a read more text is displayed if the output got trimmed');
     $this->assertNotEmpty($this->xpathContent($output, '//a[contains(@href, :path)]', [':path' => $more_path]), 'Make sure the read more link points to the right destination.');
 
     $name_field->options['alter']['more_link'] = FALSE;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertNotSubString($output, $more_text, 'Make sure no read more text appears.');
@@ -667,12 +667,12 @@ public function testTextRendering() {
     // Check for the ellipses.
     $row->views_test_data_name = $this->randomMachineName(8);
     $name_field->options['alter']['max_length'] = 5;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertSubString($output, '…', 'An ellipsis should appear if the output is trimmed');
     $name_field->options['alter']['max_length'] = 10;
-    $output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
+    $output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field, $row) {
       return $name_field->advancedRender($row);
     });
     $this->assertNotSubString($output, '…', 'No ellipsis should appear if the output is not trimmed');
diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php
index b2ca2f10315e..e68cf66b7596 100644
--- a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php
@@ -63,13 +63,13 @@ public function testArguments() {
     $this->assertSession()->statusCodeEquals(200);
     $this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url']);
     $this->assertSession()->elementsCount('xpath', $xpath, 1);
-    $this->assertSession()->elementTextEquals('xpath', $xpath, 1);
+    $this->assertSession()->elementTextEquals('xpath', $xpath, '1');
 
     // Ensure that just the filtered entry is returned.
     $this->drupalGet('test_route_with_suffix/1/suffix');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->elementsCount('xpath', $xpath, 1);
-    $this->assertSession()->elementTextEquals('xpath', $xpath, 1);
+    $this->assertSession()->elementTextEquals('xpath', $xpath, '1');
 
     // Ensure that no result is returned.
     $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/2');
@@ -80,13 +80,13 @@ public function testArguments() {
     $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/1');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->elementsCount('xpath', $xpath, 1);
-    $this->assertSession()->elementTextEquals('xpath', $xpath, 1);
+    $this->assertSession()->elementTextEquals('xpath', $xpath, '1');
 
     // Ensure that just the filtered entry is returned.
     $this->drupalGet('test_route_with_long_argument/1');
     $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->elementsCount('xpath', $xpath, 1);
-    $this->assertSession()->elementTextEquals('xpath', $xpath, 1);
+    $this->assertSession()->elementTextEquals('xpath', $xpath, '1');
   }
 
   /**
diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php
index 6a4847219e0b..2fe755f98a75 100644
--- a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php
@@ -111,7 +111,7 @@ public function testDisplayPlugin() {
     $view->style_plugin->setUsesRowPlugin(FALSE);
 
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
 
     $this->assertStringContainsString('<h1></h1>', $output, 'An empty value for test_option found in output.');
 
@@ -120,7 +120,7 @@ public function testDisplayPlugin() {
     $view->save();
 
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
 
     // Test we have our custom <h1> tag in the output of the view.
     $this->assertStringContainsString('<h1>Test option title</h1>', $output, 'The test_option value found in display output title.');
@@ -219,7 +219,7 @@ public function testReadMoreCustomURL() {
     $view->display_handler->setOption('link_url', 'node');
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node', $output, 'The read more link with href "/node" was found.');
 
     // Test more link with leading slash.
@@ -227,7 +227,7 @@ public function testReadMoreCustomURL() {
     $view->display_handler->setOption('link_url', '/node');
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node', $output, 'The read more link with href "/node" was found.');
 
     // Test more link with absolute URL.
@@ -235,7 +235,7 @@ public function testReadMoreCustomURL() {
     $view->display_handler->setOption('link_url', 'http://example.com');
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('http://example.com', $output, 'The read more link with href "http://example.com" was found.');
 
     // Test more link with query parameters in the URL.
@@ -243,7 +243,7 @@ public function testReadMoreCustomURL() {
     $view->display_handler->setOption('link_url', 'node?page=1&foo=bar');
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node?page=1&amp;foo=bar', $output, 'The read more link with href "/node?page=1&foo=bar" was found.');
 
     // Test more link with fragment in the URL.
@@ -251,7 +251,7 @@ public function testReadMoreCustomURL() {
     $view->display_handler->setOption('link_url', 'node#target');
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node#target', $output, 'The read more link with href "/node#target" was found.');
 
     // Test more link with arguments.
@@ -264,7 +264,7 @@ public function testReadMoreCustomURL() {
     $view->setArguments([22]);
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node?date=22&amp;foo=bar', $output, 'The read more link with href "/node?date=22&foo=bar" was found.');
 
     // Test more link with 1 dimension array query parameters with arguments.
@@ -277,7 +277,7 @@ public function testReadMoreCustomURL() {
     $view->setArguments([22]);
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node?f%5B0%5D=foo%3Abar&amp;f%5B1%5D=foo%3A22', $output, 'The read more link with href "/node?f[0]=foo:bar&f[1]=foo:22" was found.');
 
     // Test more link with arguments in path.
@@ -285,7 +285,7 @@ public function testReadMoreCustomURL() {
     $view->setArguments([22]);
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node/22?date=22&amp;foo=bar', $output, 'The read more link with href "/node/22?date=22&foo=bar" was found.');
 
     // Test more link with arguments in fragment.
@@ -293,7 +293,7 @@ public function testReadMoreCustomURL() {
     $view->setArguments([22]);
     $this->executeView($view);
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     $this->assertStringContainsString('/node?date=22&amp;foo=bar#22', $output, 'The read more link with href "/node?date=22&foo=bar#22" was found.');
   }
 
diff --git a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
index 64072bbf35ff..c28795bfdcd5 100644
--- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
+++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php
@@ -425,7 +425,7 @@ public function testRenderNullPager() {
     $view->setAjaxEnabled(TRUE);
     $view->pager = NULL;
     $output = $view->render();
-    $output = \Drupal::service('renderer')->renderRoot($output);
+    $output = (string) \Drupal::service('renderer')->renderRoot($output);
     $this->assertEquals(0, preg_match('/<ul class="pager">/', $output), 'The pager is not rendered.');
   }
 
-- 
GitLab