public function ShortcutLinksTest::testShortcutLinkChangePath in Drupal 10
Same name and namespace in other branches
- 8 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkChangePath()
- 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkChangePath()
Tests that changing the path of a shortcut link works.
File
- core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutLinksTest.php, line 252
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testShortcutLinkChangePath() {
$set = $this->set;
// Tests changing a shortcut path.
$new_link_path = '/admin/config';
$shortcuts = $set
->getShortcuts();
$shortcut = reset($shortcuts);
$this
->drupalGet('admin/config/user-interface/shortcut/link/' . $shortcut
->id());
$this
->submitForm([
'title[0][value]' => $shortcut
->getTitle(),
'link[0][uri]' => $new_link_path,
], 'Save');
$saved_set = ShortcutSet::load($set
->id());
$paths = $this
->getShortcutInformation($saved_set, 'link');
$this
->assertContains('internal:' . $new_link_path, $paths, 'Shortcut path changed: ' . $new_link_path);
$this
->assertSession()
->linkByHrefExists($new_link_path, 0, 'Shortcut with new path appears on the page.');
$this
->assertSession()
->pageTextContains('The shortcut ' . $shortcut
->getTitle() . ' has been updated.');
}