diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php index 2bb230e..072e8f3 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; -use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\simpletest\WebTestBase; @@ -126,27 +125,4 @@ public function testConfigurationRename() { $this->assertIdentical($staged_type, $content_type->type); } - /** - * Asserts that a Perl regex pattern is found in the text content. - * - * @param string $pattern - * Perl regex to look for including the regex delimiters. - * @param string $message - * (optional) A message to display with the assertion. - * - * @return bool - * TRUE on pass, FALSE on failure. - */ - protected function assertTextPattern($pattern, $message = NULL) { - // @see WebTestBase::assertTextHelper() - if ($this->plainTextContent === FALSE) { - $this->plainTextContent = Xss::filter($this->drupalGetContent(), array()); - } - // @see WebTestBase::assertPattern() - if (!$message) { - $message = String::format('Pattern "@pattern" found', array('@pattern' => $pattern)); - } - return $this->assert((bool) preg_match($pattern, $this->plainTextContent), $message); - } - } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/AssertContentTrait.php b/core/modules/simpletest/lib/Drupal/simpletest/AssertContentTrait.php index 47b3f95..1249f95 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/AssertContentTrait.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/AssertContentTrait.php @@ -80,6 +80,22 @@ protected function getTextContent() { } /** + * 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. + */ + protected function removeWhiteSpace() { + $this->content = preg_replace('@>\s+<@', '><', $this->content); + $this->plainTextContent = NULL; + $this->elements = NULL; + } + + /** * Gets the value of drupalSettings for the currently-loaded page. * * drupalSettings refers to the drupalSettings JavaScript variable. @@ -606,6 +622,29 @@ protected function assertNoPattern($pattern, $message = '', $group = 'Other') { } /** + * Asserts that a Perl regex pattern is found in the plain-text content. + * + * @param string $pattern + * Perl regex to look for including the regex delimiters. + * @param string $message + * (optional) A message to display with the assertion. + * @param $group + * (optional) The group this message is in, which is displayed in a column + * in test output. Use 'Debug' to indicate this is debugging output. Do not + * translate this string. Defaults to 'Other'; most tests do not override + * this default. + * + * @return bool + * TRUE on pass, FALSE on failure. + */ + protected function assertTextPattern($pattern, $message = NULL, $group = 'Other') { + if (!isset($message)) { + $message = String::format('Pattern "@pattern" found', array('@pattern' => $pattern)); + } + return $this->assert((bool) preg_match($pattern, $this->getTextContent()), $message, $group); + } + + /** * Pass if the page title is the given string. * * @param $title diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php index e7d62f3..36d4f21 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php @@ -137,11 +137,4 @@ function testThemeTableHeaderCellOption() { $this->assertRaw('111', 'The th and td tags was printed correctly.'); } - /** - * Removes all white-space between HTML tags from $this->content. - */ - protected function removeWhiteSpace() { - $this->content = preg_replace('@>\s+<@', '><', $this->content); - } - }