You are here

protected function WidgetTest::constructRangeFieldXpath in Range 8

Helper: Constructs an XPath for the given range field name.

Parameters

string $name: Field name.

Return value

string XPath for specified value.

1 call to WidgetTest::constructRangeFieldXpath()
WidgetTest::testFieldWidget in tests/src/Kernel/Widget/WidgetTest.php
Tests widget.

File

tests/src/Kernel/Widget/WidgetTest.php, line 96

Class

WidgetTest
Tests field widget.

Namespace

Drupal\Tests\range\Kernel\Widget

Code

protected function constructRangeFieldXpath($name) {
  $field_settings = $this
    ->getFieldSettings($this->fieldType);
  $widget_settings = $this
    ->getWidgetSettings();
  $xpath = '//input[@name=:name][@type=:type][@min=:min][@max=:max][@step=:step][@placeholder=:placeholder]';
  return $this
    ->buildXPathQuery($xpath, [
    ':name' => "{$this->fieldName}[0][{$name}]",
    ':type' => 'number',
    ':min' => $field_settings['min'],
    ':max' => $field_settings['max'],
    ':step' => $this
      ->getExpectedStepValue(),
    ':placeholder' => $widget_settings['placeholder'][$name],
  ]);
}