function ShortcutSetsTest::testShortcutSetAdd
Tests creating a shortcut set.
File
- 
              core/modules/ shortcut/ tests/ src/ Functional/ ShortcutSetsTest.php, line 39 
Class
- ShortcutSetsTest
- Create, view, edit, delete, and change shortcut sets.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testShortcutSetAdd() : void {
  $this->drupalGet('admin/config/user-interface/shortcut');
  $this->clickLink('Add shortcut set');
  $edit = [
    'label' => $this->randomMachineName(),
    'id' => $this->randomMachineName(),
  ];
  $this->submitForm($edit, 'Save');
  $new_set = $this->container
    ->get('entity_type.manager')
    ->getStorage('shortcut_set')
    ->load($edit['id']);
  $this->assertSame($edit['id'], $new_set->id(), 'Successfully created a shortcut set.');
  $this->drupalGet('user/' . $this->adminUser
    ->id() . '/shortcuts');
  // Verify that generated shortcut set was listed as a choice on the user
  // account page.
  $this->assertSession()
    ->pageTextContains($new_set->label());
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
