function EntityLinksTest::testMenuLinkContentEntity

@legacy-covers ::getUrl @legacy-covers \Drupal\menu_link_content\Entity\MenuLinkContentLinkTarget

File

core/modules/filter/tests/src/Kernel/EntityLinksTest.php, line 319

Class

EntityLinksTest
Tests the behavior of generating entity URLs when using entity links in CKEditor.

Namespace

Drupal\Tests\filter\Kernel

Code

public function testMenuLinkContentEntity() : void {
  $link = 'https://nl.wikipedia.org/wiki/Llama';
  $menu_link_content = MenuLinkContent::create([
    'id' => 'llama',
    'title' => 'Llama Gabilondo',
    'description' => 'Llama Gabilondo',
    'link' => $link,
    'weight' => 0,
    'menu_name' => 'main',
  ]);
  $menu_link_content->save();
  $this->assertFilterProcessResult(sprintf('<a data-entity-type="menu_link_content" data-entity-uuid="%s" href="something?query=string#fragment">Link text</a>', $menu_link_content->uuid()), 'en', (new FilterProcessResult())->setProcessedText(sprintf('<a href="%s?query=string#fragment">Link text</a>', $link))
    ->setCacheTags([
    'menu_link_content:1',
  ])
    ->setCacheContexts([])
    ->setCacheMaxAge(Cache::PERMANENT));
}

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