reverted: --- b/core/modules/field/tests/src/Kernel/Boolean/BooleanFormatterTest.php +++ a/core/modules/field/tests/src/Kernel/Boolean/BooleanFormatterTest.php @@ -138,7 +138,7 @@ // Verify that all HTML is escaped and newlines are retained. $this->renderEntityFields($entity, $this->display); + $this->assertRaw($expected); - $this->assertSession()->responseContains($expected); } } reverted: --- b/core/modules/field/tests/src/Kernel/DisplayApiTest.php +++ a/core/modules/field/tests/src/Kernel/DisplayApiTest.php @@ -172,7 +172,7 @@ $build = $items->view($display); $this->render($build); $setting = $display['settings']['test_formatter_setting_multiple']; + $this->assertRaw('visually-hidden', 'Label was visually hidden.'); - $this->assertSession()->responseContains('visually-hidden', 'Label was visually hidden.'); $this->assertText('field_test_entity_display_build_alter', 'Alter fired, display passed.'); $this->assertText('entity language is en', 'Language is placed onto the context.'); $array = []; reverted: --- b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php +++ a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php @@ -65,13 +65,13 @@ // View all fields. $content = $display->build($entity); $this->render($content); + $this->assertRaw($this->fieldTestData->field->getLabel(), "First field's label is displayed."); - $this->assertSession()->responseContains($this->fieldTestData->field->getLabel(), "First field's label is displayed."); foreach ($values as $delta => $value) { + $this->assertRaw("$formatter_setting|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); - $this->assertSession()->responseContains("$formatter_setting|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); } + $this->assertRaw($this->fieldTestData->field_2->getLabel(), "Second field's label is displayed."); - $this->assertSession()->responseContains($this->fieldTestData->field_2->getLabel(), "Second field's label is displayed."); foreach ($values_2 as $delta => $value) { + $this->assertRaw("$formatter_setting_2|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); - $this->assertSession()->responseContains("$formatter_setting_2|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); } // Label hidden. @@ -108,7 +108,7 @@ foreach ($values as $delta => $value) { $expected_output .= "|$delta:{$value['value']}"; } + $this->assertRaw($expected_output, "Multiple formatter: all values are displayed, formatter settings are applied."); - $this->assertSession()->responseContains($expected_output, "Multiple formatter: all values are displayed, formatter settings are applied."); // Test a formatter that uses hook_field_formatter_prepare_view(). $entity = clone($entity_init); @@ -124,7 +124,7 @@ $this->render($content); foreach ($values as $delta => $value) { $expected = $formatter_setting . '|' . $value['value'] . '|' . ($value['value'] + 1); + $this->assertRaw($expected, "Value $delta is displayed, formatter settings are applied."); - $this->assertSession()->responseContains($expected, "Value $delta is displayed, formatter settings are applied."); } // TODO: reverted: --- b/core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php +++ a/core/modules/field/tests/src/Kernel/String/RawStringFormatterTest.php @@ -119,7 +119,7 @@ // Verify that all HTML is escaped and newlines are retained. $this->renderEntityFields($entity, $this->display); $this->assertNoRaw($value); + $this->assertRaw(nl2br(Html::escape($value))); - $this->assertSession()->responseContains(nl2br(Html::escape($value))); // Verify the cache tags. $build = $entity->{$this->fieldName}->view(); reverted: --- b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php +++ a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php @@ -129,7 +129,7 @@ // Verify that all HTML is escaped and newlines are retained. $this->renderEntityFields($entity, $this->display); $this->assertNoRaw($value); + $this->assertRaw(nl2br(Html::escape($value))); - $this->assertSession()->responseContains(nl2br(Html::escape($value))); // Verify the cache tags. $build = $entity->{$this->fieldName}->view(); reverted: --- b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php +++ a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php @@ -136,7 +136,7 @@ $entity->{$this->fieldName}->value = $value; $this->renderEntityFields($entity, $this->display); + $this->assertRaw($expected); - $this->assertSession()->responseContains($expected); } } @@ -173,7 +173,7 @@ $entity->{$this->fieldName}->value = $value; $this->renderEntityFields($entity, $this->display); + $this->assertRaw($expected); - $this->assertSession()->responseContains($expected); // Test a timestamp in the future $value = $request_time + 87654321; @@ -188,7 +188,7 @@ $entity->{$this->fieldName}->value = $value; $this->renderEntityFields($entity, $this->display); + $this->assertRaw($expected); - $this->assertSession()->responseContains($expected); } } reverted: --- b/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php +++ a/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php @@ -118,9 +118,9 @@ $output = $this->render($form); $this->setRawContent($output); $this->assertFieldByName('textformat[value]'); + $this->assertRaw('

Full HTML

'); + $this->assertRaw('

Filtered HTML

'); + $this->assertRaw('

Test format

'); - $this->assertSession()->responseContains('

Full HTML

'); - $this->assertSession()->responseContains('

Filtered HTML

'); - $this->assertSession()->responseContains('

Test format

'); $this->assertNoPattern('|]*>|', 'No empty H4 element found.'); } reverted: --- b/core/modules/node/tests/src/Kernel/SummaryLengthTest.php +++ a/core/modules/node/tests/src/Kernel/SummaryLengthTest.php @@ -96,7 +96,7 @@ // characters of the node body, so it should be included if the summary is // 600 characters long. $expected = 'What is a Drupalism?'; + $this->assertRaw($expected); - $this->assertSession()->responseContains($expected); // Change the teaser length for "Basic page" content type. $display = \Drupal::service('entity_display.repository') reverted: --- b/core/modules/system/tests/src/Kernel/Theme/TwigFilterTest.php +++ a/core/modules/system/tests/src/Kernel/Theme/TwigFilterTest.php @@ -132,7 +132,7 @@ ]; foreach ($elements as $element) { + $this->assertRaw($element['expected'], $element['message']); - $this->assertSession()->responseContains($element['expected'], $element['message']); } } reverted: --- b/core/modules/system/tests/src/Kernel/Theme/TwigRawTest.php +++ a/core/modules/system/tests/src/Kernel/Theme/TwigRawTest.php @@ -28,7 +28,7 @@ ]; $rendered = \Drupal::service('renderer')->renderRoot($test); $this->setRawContent($rendered); + $this->assertRaw(''); - $this->assertSession()->responseContains(''); } /** reverted: --- b/core/modules/user/tests/src/Kernel/WhosOnlineBlockTest.php +++ a/core/modules/user/tests/src/Kernel/WhosOnlineBlockTest.php @@ -110,7 +110,7 @@ ->getViewBuilder($entity->getEntityTypeId()) ->view($entity, 'block'); $this->setRawContent($this->renderer->renderRoot($output)); + $this->assertRaw('2 users', 'Correct number of online users (2 users).'); - $this->assertSession()->responseContains('2 users', 'Correct number of online users (2 users).'); $this->assertText($user1->getAccountName(), 'Active user 1 found in online list.'); $this->assertText($user2->getAccountName(), 'Active user 2 found in online list.'); $this->assertNoText($user3->getAccountName(), 'Inactive user not found in online list.'); reverted: --- b/core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php +++ a/core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php @@ -57,7 +57,7 @@ $output = \Drupal::service('renderer')->renderRoot($output); $this->setRawContent($output); $this->assertText('start: 0 | end: 0 | total: 0 | label: test_area_result | per page: 0 | current page: 1 | current record count: 0 | page count: 1'); + $this->assertRaw('
'); - $this->assertSession()->responseContains('
'); // Test that the area is not displayed if we have not checked the empty // checkbox. reverted: --- b/core/modules/views/tests/src/Kernel/ViewsHooksTest.php +++ a/core/modules/views/tests/src/Kernel/ViewsHooksTest.php @@ -113,7 +113,7 @@ }); $this->setRawContent((string) $element['output']['#markup']); $this->assertEscaped('escaped'); + $this->assertRaw('unescaped'); - $this->assertSession()->responseContains('unescaped'); } } reverted: --- b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php +++ a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php @@ -786,7 +786,7 @@ $this->setRawContent($output); foreach ($expected_values as $expected_entity_values) { if ($expected_entity_values[$entity_keys['published']] === TRUE && $expected_entity_values['default_revision'] === TRUE) { + $this->assertRaw($expected_entity_values[$entity_keys['label']]); - $this->assertSession()->responseContains($expected_entity_values[$entity_keys['label']]); } // Node 4 will always appear in the 'stage' workspace because it has // both an unpublished revision as well as a published one. reverted: --- b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php +++ a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php @@ -117,10 +117,10 @@ $this->drupalGet('error-test/generate-fatals'); $this->assertResponse(500); $message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error); + $this->assertRaw((string) $message); + $this->assertRaw('
');
-    $this->assertSession()->responseContains((string) $message);
-    $this->assertSession()->responseContains('
');
     // Ensure we are escaping but not double escaping.
+    $this->assertRaw(''');
-    $this->assertSession()->responseContains(''');
     $this->assertNoRaw(''');
   }
 
@@ -160,8 +160,8 @@
     $this->drupalGet('broken-service-class');
     $this->assertResponse(500);
 
+    $this->assertRaw('The website encountered an unexpected error.');
+    $this->assertRaw($this->expectedExceptionMessage);
-    $this->assertSession()->responseContains('The website encountered an unexpected error.');
-    $this->assertSession()->responseContains($this->expectedExceptionMessage);
     $this->assertErrorLogged($this->expectedExceptionMessage);
   }
 
@@ -202,7 +202,7 @@
     $this->drupalGet('');
     $this->assertResponse(500);
 
+    $this->assertRaw($this->expectedExceptionMessage);
-    $this->assertSession()->responseContains($this->expectedExceptionMessage);
     $this->assertErrorLogged($this->expectedExceptionMessage);
   }
 
@@ -222,8 +222,8 @@
     $this->drupalGet('');
     $this->assertResponse(500);
 
+    $this->assertRaw('The website encountered an unexpected error');
+    $this->assertRaw($this->expectedExceptionMessage);
-    $this->assertSession()->responseContains('The website encountered an unexpected error');
-    $this->assertSession()->responseContains($this->expectedExceptionMessage);
     $this->assertErrorLogged($this->expectedExceptionMessage);
   }
 
@@ -258,7 +258,7 @@
 
     $this->drupalGet('');
     $this->assertResponse(500);
+    $this->assertRaw('DatabaseAccessDeniedException');
-    $this->assertSession()->responseContains('DatabaseAccessDeniedException');
     $this->assertErrorLogged($this->expectedExceptionMessage);
   }
 
@@ -275,7 +275,7 @@
     $this->drupalGet('');
     $this->assertResponse(500);
     $this->assertText('The website encountered an unexpected error. Please try again later.');
+    $this->assertRaw($this->expectedExceptionMessage);
-    $this->assertSession()->responseContains($this->expectedExceptionMessage);
 
     // Find fatal error logged to the error.log
     $errors = file(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
reverted:
--- b/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
+++ a/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
@@ -34,7 +34,7 @@
     // Make sure tableheader.js was attached.
     $tableheader = $this->xpath("//script[contains(@src, 'tableheader.js')]");
     $this->assertCount(1, $tableheader);
+    $this->assertRaw('sticky-enabled');
-    $this->assertSession()->responseContains('sticky-enabled');
   }
 
   /**
@@ -87,8 +87,8 @@
 
     $this->render($table);
     $this->removeWhiteSpace();
+    $this->assertRaw('Header 1Header 2', 'Table header found.');
+    $this->assertRaw('Empty row.', 'Colspan on #empty row found.');
-    $this->assertSession()->responseContains('Header 1Header 2', 'Table header found.');
-    $this->assertSession()->responseContains('Empty row.', 'Colspan on #empty row found.');
   }
 
   /**
@@ -129,7 +129,7 @@
 
     $this->render($table);
     $this->removeWhiteSpace();
+    $this->assertRaw('1Foo', 'Table footer found.');
-    $this->assertSession()->responseContains('1Foo', 'Table footer found.');
   }
 
   /**
@@ -149,7 +149,7 @@
     ];
     $this->render($table);
     $this->removeWhiteSpace();
+    $this->assertRaw('111', 'The th and td tags was printed correctly.');
-    $this->assertSession()->responseContains('111', 'The th and td tags was printed correctly.');
   }
 
   /**
@@ -165,7 +165,7 @@
       '#responsive' => TRUE,
     ];
     $this->render($table);
+    $this->assertRaw('responsive-enabled', 'The responsive-enabled class was printed correctly.');
-    $this->assertSession()->responseContains('responsive-enabled', 'The responsive-enabled class was printed correctly.');
   }
 
   /**
@@ -218,12 +218,12 @@
       '#responsive' => TRUE,
     ];
     $this->render($table);
+    $this->assertRaw('1', 'Header 1: the priority-medium class was applied correctly.');
+    $this->assertRaw('2', 'Header 2: the priority-low class was applied correctly.');
+    $this->assertRaw('3', 'Header 3: no priority classes were applied.');
+    $this->assertRaw('4', 'Cell 1: the priority-medium class was applied correctly.');
+    $this->assertRaw('5', 'Cell 2: the priority-low class was applied correctly.');
+    $this->assertRaw('6', 'Cell 3: no priority classes were applied.');
-    $this->assertSession()->responseContains('1', 'Header 1: the priority-medium class was applied correctly.');
-    $this->assertSession()->responseContains('2', 'Header 2: the priority-low class was applied correctly.');
-    $this->assertSession()->responseContains('3', 'Header 3: no priority classes were applied.');
-    $this->assertSession()->responseContains('4', 'Cell 1: the priority-medium class was applied correctly.');
-    $this->assertSession()->responseContains('5', 'Cell 2: the priority-low class was applied correctly.');
-    $this->assertSession()->responseContains('6', 'Cell 3: no priority classes were applied.');
   }
 
   /**
@@ -254,7 +254,7 @@
     ];
     $this->render($table);
     $this->removeWhiteSpace();
+    $this->assertRaw('onetwothree', 'Table header found.');
-    $this->assertSession()->responseContains('onetwothree', 'Table header found.');
   }
 
   /**
@@ -294,8 +294,8 @@
     ];
     $this->render($table);
     $this->removeWhiteSpace();
+    $this->assertRaw('1-one1-two1-three', 'Table row 1 found.');
+    $this->assertRaw('2-one2-two2-three', 'Table row 2 found.');
-    $this->assertSession()->responseContains('1-one1-two1-three', 'Table row 1 found.');
-    $this->assertSession()->responseContains('2-one2-two2-three', 'Table row 2 found.');
   }
 
   /**
@@ -305,7 +305,7 @@
     $form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestTableForm');
     $this->render($form);
     $this->assertEscaped('Update kitten');
+    $this->assertRaw('Update my favorite fruit is bananas');
-    $this->assertSession()->responseContains('Update my favorite fruit is bananas');
   }
 
 }
reverted:
--- b/core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php
+++ a/core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php
@@ -186,7 +186,7 @@
     // Test message is properly escaped, and that the unescaped string is not
     // output at all.
     $this->setRawContent($response->getContent());
+    $this->assertRaw(Html::escape('Escaped content: 


')); - $this->assertSession()->responseContains(Html::escape('Escaped content:


')); $this->assertNoRaw('


'); $string = ''; reverted: --- b/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php +++ a/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php @@ -60,7 +60,7 @@ $this->render($image); // Make sure sizes is set. + $this->assertRaw($sizes, 'Sizes is set correctly.'); - $this->assertSession()->responseContains($sizes, 'Sizes is set correctly.'); } /** @@ -79,7 +79,7 @@ $this->render($image); // Make sure the src attribute has the correct value. + $this->assertRaw(file_url_transform_relative(file_create_url($image['#uri'])), 'Correct output for an image with the src attribute.'); - $this->assertSession()->responseContains(file_url_transform_relative(file_create_url($image['#uri'])), 'Correct output for an image with the src attribute.'); } /** @@ -107,7 +107,7 @@ $this->render($image); // Make sure the srcset attribute has the correct value. + $this->assertRaw(file_url_transform_relative(file_create_url($this->testImages[0])) . ' 1x, ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' 2x', 'Correct output for image with srcset attribute and multipliers.'); - $this->assertSession()->responseContains(file_url_transform_relative(file_create_url($this->testImages[0])) . ' 1x, ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' 2x', 'Correct output for image with srcset attribute and multipliers.'); } /** @@ -139,7 +139,7 @@ $this->render($image); // Make sure the srcset attribute has the correct value. + $this->assertRaw(file_url_transform_relative(file_create_url($this->testImages[0])) . ' ' . $widths[0] . ', ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' ' . $widths[1], 'Correct output for image with srcset attribute and width descriptors.'); - $this->assertSession()->responseContains(file_url_transform_relative(file_create_url($this->testImages[0])) . ' ' . $widths[0] . ', ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' ' . $widths[1], 'Correct output for image with srcset attribute and width descriptors.'); } } reverted: --- b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php +++ a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php @@ -30,8 +30,8 @@ '#type' => 'status_messages', ]; $this->render($messages); + $this->assertRaw('messages messages--error'); + $this->assertRaw('messages messages--status'); - $this->assertSession()->responseContains('messages messages--error'); - $this->assertSession()->responseContains('messages messages--status'); // Tests display of only one type of messages. \Drupal::messenger()->addError('An error occurred'); $messages = [ @@ -39,7 +39,7 @@ '#display' => 'error', ]; $this->render($messages); + $this->assertRaw('messages messages--error'); - $this->assertSession()->responseContains('messages messages--error'); } } reverted: --- b/core/tests/Drupal/KernelTests/Core/Url/LinkGenerationTest.php +++ a/core/tests/Drupal/KernelTests/Core/Url/LinkGenerationTest.php @@ -29,7 +29,7 @@ $this->setRawContent($link); $this->assertInstanceOf(MarkupInterface::class, $link); // Ensure the content of the link is not escaped. + $this->assertRaw('link with markup'); - $this->assertSession()->responseContains('link with markup'); // Test just adding text to an already safe string. \Drupal::state()->set('link_generation_test_link_alter', TRUE); @@ -49,7 +49,7 @@ $this->setRawContent($link); $this->assertInstanceOf(MarkupInterface::class, $link); // Ensure the content of the link is escaped. + $this->assertRaw('link with markup Test!'); - $this->assertSession()->responseContains('link with markup Test!'); // Test passing an unsafe string to t(). $link = $renderer->executeInRenderContext(new RenderContext(), function () use ($url) { @@ -59,7 +59,7 @@ $this->assertInstanceOf(MarkupInterface::class, $link); // Ensure the content of the link is escaped. $this->assertEscaped('link with markup'); + $this->assertRaw('Test!'); - $this->assertSession()->responseContains('Test!'); } }