public function ShortcutLinksTest::testShortcutLinkOrder in Drupal 10
Same name and namespace in other branches
- 8 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkOrder()
- 9 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 384
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testShortcutLinkOrder() {
// 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());
}