function ShortcutLinksTest::testShortcutLinkChangePath

Tests that changing the path of a shortcut link works.

File

drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php, line 96
Definition of Drupal\shortcut\Tests\ShortcutLinksTest.

Class

ShortcutLinksTest
Defines shortcut links test cases.

Namespace

Drupal\shortcut\Tests

Code

function testShortcutLinkChangePath() {
  $set = $this->set;

  // Tests changing a shortcut path.
  $new_link_path = 'admin/config';
  $link = reset($set->links);
  $this
    ->drupalPost('admin/config/user-interface/shortcut/link/' . $link->mlid, array(
    'shortcut_link[link_title]' => $link->link_title,
    'shortcut_link[link_path]' => $new_link_path,
  ), t('Save'));
  $saved_set = shortcut_set_load($set
    ->id());
  $paths = $this
    ->getShortcutInformation($saved_set, 'link_path');
  $this
    ->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
  $this
    ->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.');
}