public function TestSubContext::assertEntityReferenceFieldNotContains in Panopoly 8.2
Checks, that entity reference field with has specified value.
Entity references have the entity ID appended to the title. This step allows asserting the main text value without needing to know the entity ID.
@Then /^the entity reference "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 1074 - Provide Behat step-definitions for generic Panopoly tests.
Class
- TestSubContext
- Behat sub-context for Panopoly.
Code
public function assertEntityReferenceFieldNotContains($field, $value) {
$node = $this
->assertSession()
->fieldExists($field);
$actual = $node
->getValue();
$regex = '/^' . preg_quote($value, '/') . ' \\([0-9]+\\)$/ui';
$message = sprintf('The field "%s" value is "%s", but it should not be.', $field, $actual);
if (preg_match($regex, $actual) === 1) {
throw new ExpectationException($message, $this
->getSession()
->getDriver());
}
}