You are here

function FilterUnitTest::assertNormalized in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/filter/src/Tests/FilterUnitTest.php \Drupal\filter\Tests\FilterUnitTest::assertNormalized()

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

Otherwise fails the test with a given message, similar to all the SimpleTest 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.

Parameters

$haystack: Text to look in.

$needle: Lowercase, plain text to look for.

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

$group: (optional) The group this message belongs to. Defaults to 'Other'.

Return value

bool TRUE on pass, FALSE on fail.

2 calls to FilterUnitTest::assertNormalized()
FilterUnitTest::testHtmlFilter in core/modules/filter/src/Tests/FilterUnitTest.php
Tests filter settings, defaults, access restrictions and similar.
FilterUnitTest::testNoFollowFilter in core/modules/filter/src/Tests/FilterUnitTest.php
Tests the spam deterrent.

File

core/modules/filter/src/Tests/FilterUnitTest.php, line 1156
Contains \Drupal\filter\Tests\FilterUnitTest.

Class

FilterUnitTest
Tests Filter module filters individually.

Namespace

Drupal\filter\Tests

Code

function assertNormalized($haystack, $needle, $message = '', $group = 'Other') {
  return $this
    ->assertTrue(strpos(strtolower(Html::decodeEntities($haystack)), $needle) !== FALSE, $message, $group);
}