function AssertContentTrait::removeWhiteSpace

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

Removes all white-space between HTML tags from the raw content.

White-space is only removed if there are no non-white-space characters between HTML tags.

Use this (once) after performing an operation that sets new raw content, and when you want to use e.g. assertText() but ignore potential white-space caused by HTML output templates.

6 calls to AssertContentTrait::removeWhiteSpace()
RenderTest::testRenderChildren in core/tests/Drupal/KernelTests/Core/Render/RenderTest.php
Ensures that render array children are processed correctly.
TableTest::testThemeTableFooter in core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
Tests that the 'footer' option works correctly.
TableTest::testThemeTableHeaderCellOption in core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
Tests that the 'header' option in cells works correctly.
TableTest::testThemeTableHeaderRenderArray in core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
Tests header elements with a mix of string and render array values.
TableTest::testThemeTableRowRenderArray in core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php
Tests row elements with a mix of string and render array values.

... See full list

File

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

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\KernelTests

Code

protected function removeWhiteSpace() {
    $this->content = preg_replace('@>\\s+<@', '><', $this->content);
    $this->plainTextContent = NULL;
    $this->elements = NULL;
}

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