public function WebAssert::elementAttributeContains in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/behat/mink/src/WebAssert.php \Behat\Mink\WebAssert::elementAttributeContains()
Checks that an attribute of a specific elements contains text.
Parameters
string $selectorType:
string|array $selector:
string $attribute:
string $text:
Throws
File
- vendor/
behat/ mink/ src/ WebAssert.php, line 580
Class
- WebAssert
- Mink web assertions tool.
Namespace
Behat\MinkCode
public function elementAttributeContains($selectorType, $selector, $attribute, $text) {
$element = $this
->elementAttributeExists($selectorType, $selector, $attribute);
$actual = $element
->getAttribute($attribute);
$regex = '/' . preg_quote($text, '/') . '/ui';
$message = sprintf('The text "%s" was not found in the attribute "%s" of the %s.', $text, $attribute, $this
->getMatchingElementRepresentation($selectorType, $selector));
$this
->assertElement((bool) preg_match($regex, $actual), $message, $element);
}