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('
');
- $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 1 Header 2 ', 'Table header found.');
+ $this->assertRaw('', 'Colspan on #empty row found.');
- $this->assertSession()->responseContains('Header 1 Header 2 ', 'Table header found.');
- $this->assertSession()->responseContains('', 'Colspan on #empty row found.');
}
/**
@@ -129,7 +129,7 @@
$this->render($table);
$this->removeWhiteSpace();
+ $this->assertRaw(' 1 Foo ', 'Table footer found.');
- $this->assertSession()->responseContains('1 Foo ', 'Table footer found.');
}
/**
@@ -149,7 +149,7 @@
];
$this->render($table);
$this->removeWhiteSpace();
+ $this->assertRaw('1 1 1 ', 'The th and td tags was printed correctly.');
- $this->assertSession()->responseContains('1 1 1 ', '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('one two three ', 'Table header found.');
- $this->assertSession()->responseContains('one two three ', 'Table header found.');
}
/**
@@ -294,8 +294,8 @@
];
$this->render($table);
$this->removeWhiteSpace();
+ $this->assertRaw('1-one 1-two 1-three ', 'Table row 1 found.');
+ $this->assertRaw('2-one 2-two 2-three ', 'Table row 2 found.');
- $this->assertSession()->responseContains('1-one 1-two 1-three ', 'Table row 1 found.');
- $this->assertSession()->responseContains('2-one 2-two 2-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!');
}
}