function ShortcutLinksTest::assertShortcutQuickLink

Same name in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::assertShortcutQuickLink()
  2. 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::assertShortcutQuickLink()
  3. 11.x 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.

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 490

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 : (string) new FormattableMarkup('Shortcut quick link with label %label found.', [
        '%label' => $label,
    ]);
    $this->assertArrayHasKey($index, $links, $message);
}

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