function ShortcutResourceTestBase::createEntity

Same name in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/Rest/ShortcutResourceTestBase.php \Drupal\Tests\shortcut\Functional\Rest\ShortcutResourceTestBase::createEntity()
  2. 8.9.x core/modules/shortcut/tests/src/Functional/Rest/ShortcutResourceTestBase.php \Drupal\Tests\shortcut\Functional\Rest\ShortcutResourceTestBase::createEntity()
  3. 10 core/modules/shortcut/tests/src/Functional/Rest/ShortcutResourceTestBase.php \Drupal\Tests\shortcut\Functional\Rest\ShortcutResourceTestBase::createEntity()

Overrides EntityResourceTestBase::createEntity

File

core/modules/shortcut/tests/src/Functional/Rest/ShortcutResourceTestBase.php, line 55

Class

ShortcutResourceTestBase
ResourceTestBase for Shortcut entity.

Namespace

Drupal\Tests\shortcut\Functional\Rest

Code

protected function createEntity() {
    // Create shortcut.
    $shortcut = Shortcut::create([
        'shortcut_set' => 'default',
        'title' => t('Comments'),
        'weight' => -20,
        'link' => [
            'uri' => 'internal:/admin/content/comment',
            'options' => [
                'fragment' => 'new',
            ],
        ],
    ]);
    $shortcut->save();
    return $shortcut;
}

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