function MenuLinkContentResourceTestBase::createEntity

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

Overrides EntityResourceTestBase::createEntity

File

core/modules/menu_link_content/tests/src/Functional/Rest/MenuLinkContentResourceTestBase.php, line 56

Class

MenuLinkContentResourceTestBase
ResourceTestBase for MenuLinkContent entity.

Namespace

Drupal\Tests\menu_link_content\Functional\Rest

Code

protected function createEntity() {
    $menu_link = MenuLinkContent::create([
        'id' => 'llama',
        'title' => 'Llama Gabilondo',
        'description' => 'Llama Gabilondo',
        'link' => [
            'uri' => 'https://nl.wikipedia.org/wiki/Llama',
            'options' => [
                'fragment' => 'a-fragment',
                'attributes' => [
                    'class' => [
                        'example-class',
                    ],
                ],
            ],
        ],
        'weight' => 0,
        'menu_name' => 'main',
    ]);
    $menu_link->save();
    return $menu_link;
}

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