You are here

public function HandlerTest::assertNoDuplicateField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/HandlerTest.php \Drupal\Tests\views_ui\Functional\HandlerTest::assertNoDuplicateField()
  2. 9 core/modules/views_ui/tests/src/Functional/HandlerTest.php \Drupal\Tests\views_ui\Functional\HandlerTest::assertNoDuplicateField()

Asserts that fields only appear once.

@internal

Parameters

string $field_name: The field name.

string $entity_type: The entity type to which the field belongs.

File

core/modules/views_ui/tests/src/Functional/HandlerTest.php, line 300

Class

HandlerTest
Tests handler UI for views.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function assertNoDuplicateField(string $field_name, string $entity_type) : void {
  $elements = $this
    ->xpath('//td[.=:entity_type]/preceding-sibling::td[@class="title" and .=:title]', [
    ':title' => $field_name,
    ':entity_type' => $entity_type,
  ]);
  $this
    ->assertCount(1, $elements, $field_name . ' appears just once in ' . $entity_type . '.');
}