You are here

protected function AssertContentTrait::constructFieldXpath in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()
  2. 10 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()

Helper: Constructs an XPath for the given set of attributes and value.

Parameters

string $attribute: Field attributes.

string $value: Value of field.

Return value

string XPath for specified values.

6 calls to AssertContentTrait::constructFieldXpath()
AssertContentTrait::assertField in core/tests/Drupal/KernelTests/AssertContentTrait.php
Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById in core/tests/Drupal/KernelTests/AssertContentTrait.php
Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName in core/tests/Drupal/KernelTests/AssertContentTrait.php
Asserts that a field exists with the given name and value.
AssertContentTrait::assertNoField in core/tests/Drupal/KernelTests/AssertContentTrait.php
Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById in core/tests/Drupal/KernelTests/AssertContentTrait.php
Asserts that a field does not exist with the given ID and value.

... See full list

File

core/tests/Drupal/KernelTests/AssertContentTrait.php, line 1501

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\KernelTests

Code

protected function constructFieldXpath($attribute, $value) {
  $xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]';
  return $this
    ->buildXPathQuery($xpath, [
    ':value' => $value,
  ]);
}