diff --git a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php
index a2cce36b180cea656dfd4793b8f7b101bf546bd8..fd7fbc8181022a026a429f8da93213dfd8c129c5 100644
--- a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php
+++ b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php
@@ -513,7 +513,7 @@ public function testLineBreakFilterTwigDebug(): void {
       'children' => 'Test two',
     ];
     include_once $this->root . '/core/themes/engines/twig/twig.engine';
-    $render = twig_render_template('container.html.twig', $variables);
+    $render = (string) twig_render_template('container.html.twig', $variables);
     $render = trim($render);
 
     // Render text before applying the auto paragraph filter.
diff --git a/core/modules/link/tests/src/Kernel/LinkItemSerializationTest.php b/core/modules/link/tests/src/Kernel/LinkItemSerializationTest.php
index f0e71a659e628743ffae26f92acf6218fe7f2c40..36d5b97703d373d76736f1725c2fd63a8fb92439 100644
--- a/core/modules/link/tests/src/Kernel/LinkItemSerializationTest.php
+++ b/core/modules/link/tests/src/Kernel/LinkItemSerializationTest.php
@@ -96,7 +96,7 @@ public function testLinkDeserialization() {
       ->set('query', $parsed_url['query']);
     $json = json_decode($this->serializer->serialize($entity, 'json'), TRUE);
     $json['field_test'][0]['options'] = 'string data';
-    $serialized = json_encode($json, TRUE);
+    $serialized = json_encode($json);
     $this->expectException(\LogicException::class);
     $this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "options" properties of the "field_test" field (field item class: Drupal\link\Plugin\Field\FieldType\LinkItem).');
     $this->serializer->deserialize($serialized, EntityTest::class, 'json');
diff --git a/core/modules/mysql/tests/src/Kernel/mysql/TemporaryQueryTest.php b/core/modules/mysql/tests/src/Kernel/mysql/TemporaryQueryTest.php
index 484ccc75227e98e72d0fda04c68afd0e42eef008..a2d7fcbabb86cdf08b78591ae7f71d39eda157d7 100644
--- a/core/modules/mysql/tests/src/Kernel/mysql/TemporaryQueryTest.php
+++ b/core/modules/mysql/tests/src/Kernel/mysql/TemporaryQueryTest.php
@@ -23,7 +23,7 @@ public function testTemporaryQuery() {
 
     // Assert that the table is indeed a temporary one.
     $temporary_table_info = $connection->query("SHOW CREATE TABLE {" . $table_name_test . "}")->fetchAssoc();
-    $this->stringContains($temporary_table_info["Create Table"], "CREATE TEMPORARY TABLE");
+    $this->assertStringContainsString('CREATE TEMPORARY TABLE', $temporary_table_info['Create Table']);
 
     // Assert that both have the same field names.
     $normal_table_fields = $connection->query("SELECT * FROM {test}")->fetch();
diff --git a/core/modules/node/tests/src/Kernel/Views/PathPluginTest.php b/core/modules/node/tests/src/Kernel/Views/PathPluginTest.php
index aadfeaff47480ec9b5f49bc6246ab327d5500239..c4fbd04d314d32e69415b313d264e66395521d83 100644
--- a/core/modules/node/tests/src/Kernel/Views/PathPluginTest.php
+++ b/core/modules/node/tests/src/Kernel/Views/PathPluginTest.php
@@ -86,7 +86,7 @@ public function testPathPlugin(): void {
 
     // Test with view_mode full.
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     foreach ($this->nodes as $node) {
       $this->assertStringContainsString('This is <strong>not escaped</strong> and this is ' . $node->toLink('the link')->toString(), $output, 'Make sure path field rewriting is not escaped.');
     }
diff --git a/core/modules/node/tests/src/Kernel/Views/RowPluginTest.php b/core/modules/node/tests/src/Kernel/Views/RowPluginTest.php
index 4206fa9abf8bbd5985ebb78dda3a6a9986b0439d..251ee45dc50ccc3de06cd66592b22889844094ba 100644
--- a/core/modules/node/tests/src/Kernel/Views/RowPluginTest.php
+++ b/core/modules/node/tests/src/Kernel/Views/RowPluginTest.php
@@ -98,7 +98,7 @@ public function testRowPlugin(): void {
 
     // Test with view_mode full.
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     foreach ($this->nodes as $node) {
       $this->assertStringNotContainsString($node->body->summary, $output, 'Make sure the teaser appears in the output of the view.');
       $this->assertStringContainsString($node->body->value, $output, 'Make sure the full text appears in the output of the view.');
@@ -107,7 +107,7 @@ public function testRowPlugin(): void {
     // Test with teasers.
     $view->rowPlugin->options['view_mode'] = 'teaser';
     $output = $view->preview();
-    $output = $renderer->renderRoot($output);
+    $output = (string) $renderer->renderRoot($output);
     foreach ($this->nodes as $node) {
       $this->assertStringContainsString($node->body->summary, $output, 'Make sure the teaser appears in the output of the view.');
       $this->assertStringNotContainsString($node->body->value, $output);
diff --git a/core/modules/user/tests/src/Kernel/WhoIsOnlineBlockTest.php b/core/modules/user/tests/src/Kernel/WhoIsOnlineBlockTest.php
index 0b329c96fb61bb9eea72d061c61262abc51ae311..c9b52afa3494527a4ecc1201c33ea1c434a603d8 100644
--- a/core/modules/user/tests/src/Kernel/WhoIsOnlineBlockTest.php
+++ b/core/modules/user/tests/src/Kernel/WhoIsOnlineBlockTest.php
@@ -123,7 +123,8 @@ public function testWhoIsOnlineBlock() {
     $this->assertText($user2->getAccountName(), 'Active user 2 found in online list.');
     $this->assertNoText($user3->getAccountName(), 'Inactive user not found in online list.');
     // Verify that online users are ordered correctly.
-    $this->assertGreaterThan(strpos($this->getRawContent(), $user2->getAccountName()), strpos($this->getRawContent(), $user1->getAccountName()));
+    $raw_content = (string) $this->getRawContent();
+    $this->assertGreaterThan(strpos($raw_content, $user2->getAccountName()), strpos($raw_content, $user1->getAccountName()));
   }
 
 }
diff --git a/core/modules/views/tests/src/Kernel/Handler/ComputedBundleFieldTest.php b/core/modules/views/tests/src/Kernel/Handler/ComputedBundleFieldTest.php
index cb1fd31d008e5000459eed90d779170737ddc0c0..8632f9c0f78d60c5aa0bc6927f031968071940e5 100644
--- a/core/modules/views/tests/src/Kernel/Handler/ComputedBundleFieldTest.php
+++ b/core/modules/views/tests/src/Kernel/Handler/ComputedBundleFieldTest.php
@@ -84,9 +84,9 @@ public function testComputedFieldHandler() {
 
     // Entities 1 and 2 should have the computed bundle field. But entity 3
     // should not.
-    $this->assertStringContainsString('some other string that is also computed', $view->field['computed_bundle_field']->render($view->result[0]));
-    $this->assertStringContainsString('some other string that is also computed', $view->field['computed_bundle_field']->render($view->result[1]));
-    $this->assertStringNotContainsString('some other string that is also computed', $view->field['computed_bundle_field']->render($view->result[2]));
+    $this->assertStringContainsString('some other string that is also computed', (string) $view->field['computed_bundle_field']->render($view->result[0]));
+    $this->assertStringContainsString('some other string that is also computed', (string) $view->field['computed_bundle_field']->render($view->result[1]));
+    $this->assertStringNotContainsString('some other string that is also computed', (string) $view->field['computed_bundle_field']->render($view->result[2]));
 
     $view->destroy();
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php
index 588fecae8c5be0fb7cac307e33523f3c0f4030f7..383537bceb1b916dd3ac42e0d299c7f85498ae28 100644
--- a/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Path/PathValidatorTest.php
@@ -64,8 +64,10 @@ public function testGetUrlIfValidWithoutAccessCheck() {
         }
         $this->container->set('router.request_context', new RequestContext());
       }
+      else {
+        $requestContext->setMethod($method);
+      }
 
-      $requestContext->setMethod($method);
       /** @var \Drupal\Core\Url $url */
       $url = $pathValidator->getUrlIfValidWithoutAccessCheck($entity->toUrl()->toString(TRUE)->getGeneratedUrl());
       $this->assertEquals($method, $requestContext->getMethod());
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ClaroTableTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ClaroTableTest.php
index 213f54b34e78c8776c6440d58475f63911ef6126..cb3e0ff35efaa1ee03d9960649605201d782b8bc 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/ClaroTableTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/ClaroTableTest.php
@@ -64,7 +64,7 @@ public function testThemeTablePositionStickyPreRender(): void {
       ],
     ];
 
-    $renderedTable = \Drupal::service('renderer')->renderRoot($table);
+    $renderedTable = (string) \Drupal::service('renderer')->renderRoot($table);
 
     // Confirm that table is rendered.
     $this->assertStringContainsString('class="class"', $renderedTable);