You are here

public function WebAssert::elementContains in Zircon Profile 8

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

Checks that specific element contains HTML.

Parameters

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

string|array $selector element selector:

string $html expected text:

Throws

ElementHtmlException

File

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

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function elementContains($selectorType, $selector, $html) {
  $element = $this
    ->elementExists($selectorType, $selector);
  $actual = $element
    ->getHtml();
  $regex = '/' . preg_quote($html, '/') . '/ui';
  $message = sprintf('The string "%s" was not found in the HTML of the %s.', $html, $this
    ->getMatchingElementRepresentation($selectorType, $selector));
  $this
    ->assertElement((bool) preg_match($regex, $actual), $message, $element);
}