diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php index 27202ba..9397168 100644 --- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php @@ -262,6 +262,24 @@ public function testAccessShortcutsPermission() { } /** + * Tests the shortcuts are correctly ordered by weight in the toolbar. + */ + public function testShortcutLinkOrder() { + $this->drupalLogin($this->drupalCreateUser(array('access toolbar', 'access shortcuts'))); + $this->drupalGet(Url::fromRoute('')); + $shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .menu a'); + $this->assertEqual((string) $shortcuts[0], 'Add content'); + $this->assertEqual((string) $shortcuts[1], 'All content'); + foreach($this->set->getShortcuts() as $shortcut) { + $shortcut->setWeight($shortcut->getWeight() * -1)->save(); + } + $this->drupalGet(Url::fromRoute('')); + $shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .menu a'); + $this->assertEqual((string) $shortcuts[0], 'All content'); + $this->assertEqual((string) $shortcuts[1], 'Add content'); + } + + /** * Tests that the 'access shortcuts' permission is required for shortcut set * administration page access. */ diff --git a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php index 34f394d..c321bc4 100644 --- a/core/modules/shortcut/src/Tests/ShortcutSetsTest.php +++ b/core/modules/shortcut/src/Tests/ShortcutSetsTest.php @@ -79,9 +79,10 @@ function testShortcutSetEdit() { $this->drupalPostForm(NULL, $edit, t('Save changes')); $this->assertRaw(t('The shortcut set has been updated.')); - // Check to ensure that the shortcut weights have changed. - $weights = $this->getShortcutInformation($set, 'weight'); - $this->assertEqual($weights, array(2, 1)); + \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + // Check to ensure that the shortcut weights have changed and that + // ShortcutSet::.getShortcuts() returns shortcuts in the new order. + $this->assertIdentical(array_reverse(array_keys($shortcuts)), array_keys($set->getShortcuts())); } /**