function ShortcutLinksTest::testShortcutLinkOrder
Same name in other branches
- 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkOrder()
- 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkOrder()
- 11.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkOrder()
Tests the shortcuts are correctly ordered by weight in the toolbar.
File
-
core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutLinksTest.php, line 408
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testShortcutLinkOrder() : void {
// Ensure to give permissions to access the shortcuts.
$this->drupalLogin($this->drupalCreateUser([
'access toolbar',
'access shortcuts',
'access content overview',
'administer content types',
]));
$this->drupalGet(Url::fromRoute('<front>'));
$shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .toolbar-menu a');
$this->assertEquals('Add content', $shortcuts[0]->getText());
$this->assertEquals('All content', $shortcuts[1]->getText());
foreach ($this->set
->getShortcuts() as $shortcut) {
$shortcut->setWeight($shortcut->getWeight() * -1)
->save();
}
$this->drupalGet(Url::fromRoute('<front>'));
$shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .toolbar-menu a');
$this->assertEquals('All content', $shortcuts[0]->getText());
$this->assertEquals('Add content', $shortcuts[1]->getText());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.