function ViewsIntegrationTest::assertOneLink

Same name and namespace in other branches
  1. main core/modules/search/tests/src/Functional/views/ViewsIntegrationTest.php \Drupal\Tests\search\Functional\views\ViewsIntegrationTest::assertOneLink()

Asserts that exactly one link exists with the given text.

@internal

Parameters

string $label: Link label to assert.

File

core/modules/search/tests/src/Functional/views/ViewsIntegrationTest.php, line 152

Class

ViewsIntegrationTest
Tests search integration filters.

Namespace

Drupal\Tests\search\Functional\views

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.