You are here

protected function ShortcutLinksTest::assertShortcutQuickLink in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::assertShortcutQuickLink()
  2. 10 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.

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.

string $group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default.

Return value

bool TRUE if the assertion succeeded.

1 call to ShortcutLinksTest::assertShortcutQuickLink()
ShortcutLinksTest::testShortcutQuickLink in core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
Tests that the "add to shortcut" and "remove from shortcut" links work.

File

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

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

protected function assertShortcutQuickLink($label, $index = 0, $message = '', $group = 'Other') {
  $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);
  return TRUE;
}