function ShortcutLinksTest::testShortcutLinkChangePath

Same name and namespace in other branches
  1. 11.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkChangePath()
  2. 10 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkChangePath()
  3. 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkChangePath()

Tests that changing the path of a shortcut link works.

File

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

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutLinkChangePath() {
  $set = $this->set;
  // Tests changing a shortcut path.
  $new_link_path = '/admin/config';
  $shortcuts = $set->getShortcuts();
  $shortcut = reset($shortcuts);
  $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), [
    'title[0][value]' => $shortcut->getTitle(),
    'link[0][uri]' => $new_link_path,
  ], t('Save'));
  $saved_set = ShortcutSet::load($set->id());
  $paths = $this->getShortcutInformation($saved_set, 'link');
  $this->assertContains('internal:' . $new_link_path, $paths, 'Shortcut path changed: ' . $new_link_path);
  $this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.');
  $this->assertText(t('The shortcut @link has been updated.', [
    '@link' => $shortcut->getTitle(),
  ]));
}

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