You are here

public function WebAssert::fieldValueEquals in Zircon Profile 8

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

Checks that specific field have provided value.

Parameters

string $field field id|name|label|value:

string $value field value:

TraversableElement $container document to check against:

Throws

ExpectationException

File

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

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function fieldValueEquals($field, $value, TraversableElement $container = null) {
  $node = $this
    ->fieldExists($field, $container);
  $actual = $node
    ->getValue();
  $regex = '/^' . preg_quote($value, '/') . '$/ui';
  $message = sprintf('The field "%s" value is "%s", but "%s" expected.', $field, $actual, $value);
  $this
    ->assert((bool) preg_match($regex, $actual), $message);
}