Commit d2c38c45 authored by alexpott's avatar alexpott
Browse files

Issue #2478151 by willzyx: Shortcuts to pages generated by views are not...

Issue #2478151 by willzyx: Shortcuts to pages generated by views are not recognized as added to the shortcutset and are being added multiple times
parent 67f0d68f
...@@ -321,7 +321,7 @@ function shortcut_preprocess_page(&$variables) { ...@@ -321,7 +321,7 @@ function shortcut_preprocess_page(&$variables) {
$shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id())); $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id()));
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */ /** @var \Drupal\shortcut\ShortcutInterface $shortcut */
foreach ($shortcuts as $shortcut) { foreach ($shortcuts as $shortcut) {
if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getParameters()->all()) { if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName()) {
$shortcut_id = $shortcut->id(); $shortcut_id = $shortcut->id();
break; break;
} }
......
...@@ -135,6 +135,24 @@ public function testShortcutQuickLink() { ...@@ -135,6 +135,24 @@ public function testShortcutQuickLink() {
$this->drupalGet('admin/structure'); $this->drupalGet('admin/structure');
$this->assertNoLink('Cron', 'Shortcut link removed from different page'); $this->assertNoLink('Cron', 'Shortcut link removed from different page');
$this->drupalGet('admin/people');
// Test the "Add to shortcuts" link for a page generated by views.
$this->clickLink('Add to Default shortcuts');
$this->assertText('Added a shortcut for People.');
// Due to the structure of the markup in the link ::assertLink() doesn't
// works here.
$link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Remove from Default shortcuts'));
$this->assertTrue(!empty($link), 'Link Remove from Default shortcuts found.');
// Test the "Remove from shortcuts" link for a page generated by views.
$this->clickLink('Remove from Default shortcuts');
$this->assertText('The shortcut People has been deleted.');
// Due to the structure of the markup in the link ::assertLink() doesn't
// works here.
$link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Add to Default shortcuts'));
$this->assertTrue(!empty($link), 'Link Add to Default shortcuts found.');
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment