diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index f367ec9d06c714bcde072f398e098e42ac41b353..0925b0cf4a8327a274f9cda55dcf42ff05f526b2 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -68,18 +68,33 @@ public function testShortcutLinkAdd() { } /** - * Tests that the "add to shortcut" link changes to "remove shortcut". + * Tests that the "add to shortcut" and "remove from shortcut" links work. */ public function testShortcutQuickLink() { theme_enable(array('seven')); \Drupal::config('system.theme')->set('admin', 'seven')->save(); $this->container->get('config.factory')->get('node.settings')->set('use_admin_theme', '1')->save(); - $shortcuts = $this->set->getShortcuts(); - $shortcut = reset($shortcuts); + $this->drupalLogin($this->root_user); + $this->drupalGet('admin/config/system/cron'); + + // Test the "Add to shortcuts" link. + $this->clickLink('Add to Default shortcuts'); + $this->assertText('Added a shortcut for Cron.'); + $this->assertLink('Cron', 0, 'Shortcut link found on page'); + + $this->drupalGet('admin/structure'); + $this->assertLink('Cron', 0, 'Shortcut link found on different page'); + + // Test the "Remove from shortcuts" link. + $this->clickLink('Cron'); + $this->clickLink('Remove from Default shortcuts'); + $this->drupalPostForm(NULL, array(), 'Delete'); + $this->assertText('The shortcut Cron has been deleted.'); + $this->assertNoLink('Cron', 'Shortcut link removed from page'); - $this->drupalGet($shortcut->path->value); - $this->assertRaw(t('Remove from %title shortcuts', array('%title' => $this->set->label())), '"Add to shortcuts" link properly switched to "Remove from shortcuts".'); + $this->drupalGet('admin/structure'); + $this->assertNoLink('Cron', 'Shortcut link removed from different page'); } /** diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index e18162b76ecd1fd164dca588b589d95e3b7afca9..56317453e3a78585093a4a2f2cd46c3f803ae4ea 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -407,8 +407,8 @@ function shortcut_preprocess_page(&$variables) { } $query = array( - 'link' => $link, - 'name' => drupal_get_title(), + 'link' => $link, + 'name' => $variables['title'], ); $query += drupal_get_destination();