You are here

protected function SearchIntegrationTest::assertOneLink in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/SearchIntegrationTest.php \Drupal\Tests\views\Functional\SearchIntegrationTest::assertOneLink()
  2. 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.

Parameters

string $label: Link label to assert.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

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 151

Class

SearchIntegrationTest
Tests search integration filters.

Namespace

Drupal\Tests\views\Functional

Code

protected function assertOneLink($label) {
  $links = $this
    ->xpath('//a[normalize-space(text())=:label]', [
    ':label' => $label,
  ]);
  $message = new FormattableMarkup('Link with label %label found once.', [
    '%label' => $label,
  ]);
  return $this
    ->assert(isset($links[0]) && !isset($links[1]), $message);
}