You are here

protected function MenuLinkContentResourceTestBase::createEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/menu_link_content/tests/src/Functional/Rest/MenuLinkContentResourceTestBase.php \Drupal\Tests\menu_link_content\Functional\Rest\MenuLinkContentResourceTestBase::createEntity()
  2. 9 core/modules/menu_link_content/tests/src/Functional/Rest/MenuLinkContentResourceTestBase.php \Drupal\Tests\menu_link_content\Functional\Rest\MenuLinkContentResourceTestBase::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityResourceTestBase::createEntity

File

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

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;
}