You are here

protected function XssTest::assertNormalized in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::assertNormalized()
  2. 9 core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::assertNormalized()

Asserts that a text transformed to lowercase with HTML entities decoded does contain a given string.

Otherwise fails the test with a given message, similar to all the PHPUnit assert* functions.

Note that this does not remove nulls, new lines and other characters that could be used to obscure a tag or an attribute name.

@internal

Parameters

string $haystack: Text to look in.

string $needle: Lowercase, plain text to look for.

string $message: (optional) Message to display if failed. Defaults to an empty string.

1 call to XssTest::assertNormalized()
XssTest::testFilterXssNormalized in core/tests/Drupal/Tests/Component/Utility/XssTest.php
Tests limiting allowed tags and XSS prevention.

File

core/tests/Drupal/Tests/Component/Utility/XssTest.php, line 600

Class

XssTest
XSS Filtering tests.

Namespace

Drupal\Tests\Component\Utility

Code

protected function assertNormalized(string $haystack, string $needle, string $message = '') : void {
  $this
    ->assertStringContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
}