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. 10 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.

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, FALSE otherwise.

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 470

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,
    ]);
    return $this->assert(isset($links[$index]), $message, $group);
}

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