You are here

protected function ShortcutLinksTest::assertShortcutQuickLink in Drupal 10

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

Passes if a shortcut quick link with the specified label is found.

An optional link index may be passed.

@internal

Parameters

string $label: Text between the anchor tags.

int $index: Link position counting from zero.

string $message: (optional) A message to display with the assertion. Do not translate messages: use new FormattableMarkup() to embed variables in the message text, not t(). If left blank, a default message will be displayed.

File

core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php, line 468

Class

ShortcutLinksTest
Create, view, edit, delete, and change shortcut links.

Namespace

Drupal\Tests\shortcut\Functional

Code

protected function assertShortcutQuickLink(string $label, int $index = 0, string $message = '') : void {
  $links = $this
    ->xpath('//a[normalize-space()=:label]', [
    ':label' => $label,
  ]);
  $message = $message ? $message : new FormattableMarkup('Shortcut quick link with label %label found.', [
    '%label' => $label,
  ]);
  $this
    ->assertArrayHasKey($index, $links, $message);
}