public function FeatureContext::assertFieldContains in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 behat-tests/features/bootstrap/FeatureContext.php \FeatureContext::assertFieldContains()
@Then the :field field should contain text that has :needle
Throws
\Exception If the the substring cannot be found in the given field.
File
- behat-tests/
features/ bootstrap/ FeatureContext.php, line 410
Class
- FeatureContext
- Defines application features from the specific context.
Code
public function assertFieldContains($field, $needle) {
$node = $this
->assertSession()
->fieldExists($field);
$haystack = $node
->getValue();
if (strpos($haystack, $needle) === false) {
throw new \Exception(sprintf('The field "%s" value is "%s", but we are looking for "%s".', $field, $haystack, $needle));
}
}