function AssertContentTrait::constructFieldXpath

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()
  2. 8.9.x core/tests/Drupal/KernelTests/AssertContentTrait.php \Drupal\KernelTests\AssertContentTrait::constructFieldXpath()
  3. 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 1280

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,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.