You are here

protected function NameWidgetTest::assertFieldByTypeAndName in Name Field 8

Asserts that the given field exists.

@todo Replace calls to this method using Mink's NodeElement::getValue().

Parameters

string $type: The form field type, for example 'input' or 'select'.

string $name: The form field full name.

mixed $value: The expected value that the form field has.

string $message: The failure message.

1 call to NameWidgetTest::assertFieldByTypeAndName()
NameWidgetTest::testFieldEntry in tests/src/Functional/NameWidgetTest.php
The most basic test.

File

tests/src/Functional/NameWidgetTest.php, line 331

Class

NameWidgetTest
Various tests on creating a name widget on a node.

Namespace

Drupal\Tests\name\Functional

Code

protected function assertFieldByTypeAndName($type, $name, $value = NULL, $message = NULL) {
  if (!isset($message)) {
    if (!isset($value)) {
      $message = new FormattableMarkup('Found @type field with name @name', [
        '@name' => var_export($name, TRUE),
        '@type' => $type,
      ]);
    }
    else {
      $message = new FormattableMarkup('Found @type field with name @name and value @value', [
        '@name' => var_export($name, TRUE),
        '@type' => $type,
        '@value' => var_export($value, TRUE),
      ]);
    }
  }
  return $this
    ->assertFieldByXPath($this
    ->constructFieldXpathByTypeAndAttribute($type, 'name', $name), $value, $message);
}