function AssertContentTrait::removeWhiteSpace

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

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

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