diff --git a/src/WebAssert.php b/src/WebAssert.php index b03c9829e..3a079599e 100644 --- a/src/WebAssert.php +++ b/src/WebAssert.php @@ -494,17 +494,19 @@ public function elementTextNotContains($selectorType, $selector, $text) /** * Checks that specific element contains HTML. * - * @param string $selectorType element selector type (css, xpath) - * @param string|array $selector element selector - * @param string $html expected text + * @param string $selectorType element selector type (css, xpath) + * @param string|array $selector element selector + * @param string $html expected text + * @param bool $caseSensitive use case sensitive comparison * * @throws ElementHtmlException */ - public function elementContains($selectorType, $selector, $html) + public function elementContains($selectorType, $selector, $html, $caseSensitive = false) { $element = $this->elementExists($selectorType, $selector); $actual = $element->getHtml(); - $regex = '/'.preg_quote($html, '/').'/ui'; + $regex = '/'.preg_quote($html, '/').'/u'; + if ($caseSensitive === false) $regex .= 'i'; $message = sprintf( 'The string "%s" was not found in the HTML of the %s.', @@ -518,17 +520,19 @@ public function elementContains($selectorType, $selector, $html) /** * Checks that specific element does not contains HTML. * - * @param string $selectorType element selector type (css, xpath) - * @param string|array $selector element selector - * @param string $html expected text + * @param string $selectorType element selector type (css, xpath) + * @param string|array $selector element selector + * @param string $html expected text + * @param bool $caseSensitive use case sensitive comparison * * @throws ElementHtmlException */ - public function elementNotContains($selectorType, $selector, $html) + public function elementNotContains($selectorType, $selector, $html, $caseSensitive = false) { $element = $this->elementExists($selectorType, $selector); $actual = $element->getHtml(); - $regex = '/'.preg_quote($html, '/').'/ui'; + $regex = '/'.preg_quote($html, '/').'/u'; + if ($caseSensitive === false) $regex .= 'i'; $message = sprintf( 'The string "%s" appears in the HTML of the %s, but it should not.',