You are here

protected function AssertContentTrait::assertTextPattern in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/AssertContentTrait.php \Drupal\simpletest\AssertContentTrait::assertTextPattern()

Asserts that a Perl regex pattern is found in the plain-text content.

Parameters

string $pattern: Perl regex to look for including the regex delimiters.

string $message: (optional) A message to display with the assertion.

string $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 value

bool TRUE on pass, FALSE on failure.

1 call to AssertContentTrait::assertTextPattern()
ThemeTest::testInstallAndSetAsDefault in core/modules/system/src/Tests/System/ThemeTest.php
Tests installing a theme and setting it as default.

File

core/modules/simpletest/src/AssertContentTrait.php, line 778
Contains \Drupal\simpletest\AssertContentTrait.

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\simpletest

Code

protected function assertTextPattern($pattern, $message = NULL, $group = 'Other') {
  if (!isset($message)) {
    $message = SafeMarkup::format('Pattern "@pattern" found', array(
      '@pattern' => $pattern,
    ));
  }
  return $this
    ->assert((bool) preg_match($pattern, $this
    ->getTextContent()), $message, $group);
}