public function ShortcutLinksTest::testShortcutLinkChangePath in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/shortcut/src/Tests/ShortcutLinksTest.php \Drupal\shortcut\Tests\ShortcutLinksTest::testShortcutLinkChangePath()
Tests that changing the path of a shortcut link works.
File
- core/modules/ shortcut/ src/ Tests/ ShortcutLinksTest.php, line 217 
- Contains \Drupal\shortcut\Tests\ShortcutLinksTest.
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\shortcut\TestsCode
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(), array(
    '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
    ->assertTrue(in_array('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.', array(
    '@link' => $shortcut
      ->getTitle(),
  )));
}