function AssertContentTrait::getTextContent

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::getTextContent()
  2. 8.9.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::getTextContent()
  3. 11.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::getTextContent()

Retrieves the plain-text content from the current raw content.

4 calls to AssertContentTrait::getTextContent()
AssertContentTrait::assertTextHelper in core/tests/Drupal/KernelTests/AssertContentTrait.php
Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern in core/tests/Drupal/KernelTests/AssertContentTrait.php
Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertUniqueTextHelper in core/tests/Drupal/KernelTests/AssertContentTrait.php
Helper for assertUniqueText and assertNoUniqueText.
AssertContentTraitTest::testGetTextContent in core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php
@covers ::getTextContent

File

core/tests/Drupal/KernelTests/AssertContentTrait.php, line 73

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\KernelTests

Code

protected function getTextContent() {
    if (!isset($this->plainTextContent)) {
        $raw_content = $this->getRawContent();
        // Strip everything between the HEAD tags.
        $raw_content = preg_replace('@<head>(.+?)</head>@si', '', $raw_content);
        $this->plainTextContent = Xss::filter($raw_content, []);
    }
    return $this->plainTextContent;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.