protected function AssertContentTrait::assertTextHelper in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::assertTextHelper()
- 9 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::assertTextHelper()
Helper for assertText and assertNoText.
It is not recommended to call this function directly.
Parameters
string $text: Plain text to look for.
string $message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Render\FormattableMarkup to embed variables in the message text, not t(). If left blank, a default message will be displayed.
string $group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default. Defaults to 'Other'.
bool $not_exists: (optional) TRUE if this text should not exist, FALSE if it should. Defaults to TRUE.
File
- core/
tests/ Drupal/ KernelTests/ AssertContentTrait.php, line 577
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\KernelTestsCode
protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE) : void {
if (!$message) {
$message = !$not_exists ? new FormattableMarkup('"@text" found', [
'@text' => $text,
]) : new FormattableMarkup('"@text" not found', [
'@text' => $text,
]);
}
if ($not_exists) {
$this
->assertStringNotContainsString((string) $text, $this
->getTextContent(), $message);
}
else {
$this
->assertStringContainsString((string) $text, $this
->getTextContent(), $message);
}
}