You are here

public function ShortcutLinksTest::testShortcutLinkRename in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkRename()
  2. 10 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkRename()

Tests that shortcut links can be renamed.

File

core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php, line 232

Class

ShortcutLinksTest
Create, view, edit, delete, and change shortcut links.

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutLinkRename() {
  $set = $this->set;

  // Attempt to rename shortcut link.
  $new_link_name = $this
    ->randomMachineName();
  $shortcuts = $set
    ->getShortcuts();
  $shortcut = reset($shortcuts);
  $this
    ->drupalGet('admin/config/user-interface/shortcut/link/' . $shortcut
    ->id());
  $this
    ->submitForm([
    'title[0][value]' => $new_link_name,
  ], 'Save');
  $saved_set = ShortcutSet::load($set
    ->id());
  $titles = $this
    ->getShortcutInformation($saved_set, 'title');
  $this
    ->assertContains($new_link_name, $titles, 'Shortcut renamed: ' . $new_link_name);
  $this
    ->assertSession()
    ->linkExists($new_link_name, 0, 'Renamed shortcut link appears on the page.');
  $this
    ->assertSession()
    ->pageTextContains('The shortcut ' . $new_link_name . ' has been updated.');
}