function ShortcutTestBase::generateShortcutSet

Creates a generic shortcut set.

7 calls to ShortcutTestBase::generateShortcutSet()
ShortcutSetsTest::testShortcutSetAdd in drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
Tests creating a shortcut set.
ShortcutSetsTest::testShortcutSetAssign in drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
Tests switching another user's shortcut set.
ShortcutSetsTest::testShortcutSetCreateWithSetName in drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
Tests creating a new shortcut set with a defined set name.
ShortcutSetsTest::testShortcutSetDelete in drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
Tests deleting a shortcut set.
ShortcutSetsTest::testShortcutSetRenameAlreadyExists in drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
Tests renaming a shortcut set to the same name as another set.

... See full list

File

drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php, line 87
Definition of Drupal\shortcut\Tests\ShortcutTestBase.

Class

ShortcutTestBase
Defines base class for shortcut test cases.

Namespace

Drupal\shortcut\Tests

Code

function generateShortcutSet($label = '', $id = NULL, $default_links = TRUE) {
  $set = entity_create('shortcut', array(
    'id' => isset($id) ? $id : strtolower($this
      ->randomName()),
    'label' => empty($label) ? $this
      ->randomString() : $label,
  ));
  if ($default_links) {
    $menu_link = $this
      ->generateShortcutLink('node/add');
    $set->links[$menu_link
      ->uuid()] = $menu_link;
    $menu_link = $this
      ->generateShortcutLink('admin/content');
    $set->links[$menu_link
      ->uuid()] = $menu_link;
  }
  $set
    ->save();
  return $set;
}