Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WebAssert.php

function WebAssert::fieldValueNotEquals

Checks that specific field have provided value.

Parameters

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

string $value field value:

TraversableElement|null $container document to check against:

Return value

void

Throws

ExpectationException

File

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

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function fieldValueNotEquals(string $field, string $value, ?TraversableElement $container = null) {
    $node = $this->fieldExists($field, $container);
    $actual = $node->getValue();
    if (\is_array($actual)) {
        throw new \LogicException('Field value assertions cannot be used for multi-select fields as they have multiple values.');
    }
    $actual = (string) $actual;
    $regex = '/^' . preg_quote($value, '/') . '$/ui';
    $message = sprintf('The field "%s" value is "%s", but it should not be.', $field, $actual);
    $this->assert(!preg_match($regex, $actual), $message);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal