You are here

protected function AssertContentTrait::removeWhiteSpace in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::removeWhiteSpace()
  2. 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 93

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;
}