function SearchIntegrationTest::assertOneLink

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/SearchIntegrationTest.php \Drupal\Tests\views\Functional\SearchIntegrationTest::assertOneLink()
  2. 8.9.x core/modules/views/tests/src/Functional/SearchIntegrationTest.php \Drupal\Tests\views\Functional\SearchIntegrationTest::assertOneLink()
  3. 10 core/modules/views/tests/src/Functional/SearchIntegrationTest.php \Drupal\Tests\views\Functional\SearchIntegrationTest::assertOneLink()

Asserts that exactly one link exists with the given text.

@internal

Parameters

string $label: Link label to assert.

1 call to SearchIntegrationTest::assertOneLink()
SearchIntegrationTest::testSearchIntegration in core/modules/views/tests/src/Functional/SearchIntegrationTest.php
Tests search integration.

File

core/modules/views/tests/src/Functional/SearchIntegrationTest.php, line 149

Class

SearchIntegrationTest
Tests search integration filters.

Namespace

Drupal\Tests\views\Functional

Code

protected function assertOneLink(string $label) : void {
    $xpath = $this->assertSession()
        ->buildXPathQuery('//a[normalize-space(text())=:label]', [
        ':label' => $label,
    ]);
    $this->assertSession()
        ->elementsCount('xpath', $xpath, 1);
}

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