function HandlerTest::assertNoDuplicateField

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

Asserts that fields only appear once.

Parameters

string $field_name: The field name.

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

1 call to HandlerTest::assertNoDuplicateField()
HandlerTest::testNoDuplicateFields in core/modules/views_ui/tests/src/Functional/HandlerTest.php
Ensures that neither node type or node ID appears multiple times.

File

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

Class

HandlerTest
Tests handler UI for views.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function assertNoDuplicateField($field_name, $entity_type) {
    $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 . '.');
}

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