function ShortcutLinksTest::testShortcutLinkRename

Same name and namespace in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkRename()
  2. 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkRename()
  3. 11.x 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 256

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutLinkRename() : void {
  $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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.