You are here

public function WebAssert::elementTextContains in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink/src/WebAssert.php \Behat\Mink\WebAssert::elementTextContains()

Checks that specific element contains text.

Parameters

string $selectorType element selector type (css, xpath):

string|array $selector element selector:

string $text expected text:

Throws

ElementTextException

File

vendor/behat/mink/src/WebAssert.php, line 457

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function elementTextContains($selectorType, $selector, $text) {
  $element = $this
    ->elementExists($selectorType, $selector);
  $actual = $element
    ->getText();
  $regex = '/' . preg_quote($text, '/') . '/ui';
  $message = sprintf('The text "%s" was not found in the text of the %s.', $text, $this
    ->getMatchingElementRepresentation($selectorType, $selector));
  $this
    ->assertElementText((bool) preg_match($regex, $actual), $message, $element);
}