function ShortcutEntityLinksTest::testShortcutEntity
Same name and namespace in other branches
- 11.x core/modules/shortcut/tests/src/Kernel/ShortcutEntityLinksTest.php \Drupal\Tests\shortcut\Kernel\ShortcutEntityLinksTest::testShortcutEntity()
@legacy-covers ::getUrl @legacy-covers \Drupal\shortcut\Entity\ShortcutLinkTarget
File
-
core/
modules/ shortcut/ tests/ src/ Kernel/ ShortcutEntityLinksTest.php, line 64
Class
- ShortcutEntityLinksTest
- Tests the entity_links filter with shortcut entities.
Namespace
Drupal\Tests\shortcut\KernelCode
public function testShortcutEntity() : void {
// cspell:disable-next-line
$path = '/user/logout?token=fzL0Ox4jS6qafdt6gzGzjWGb_hsR6kJ8L8E0D4hC5Mo';
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => 'Comments',
'weight' => -20,
'link' => [
'uri' => "internal:{$path}",
],
]);
$shortcut->save();
$result = $this->filter
->process(sprintf('<a data-entity-type="shortcut" data-entity-uuid="%s" href="something?query=string#fragment">Link text</a>', $shortcut->uuid()), 'en');
$expected_result = (new FilterProcessResult())->setProcessedText(sprintf('<a href="%s?query=string#fragment">Link text</a>', $path))
->setCacheTags([
'config:shortcut.set.default',
])
->setCacheContexts([])
->setCacheMaxAge(Cache::PERMANENT);
$this->assertSame($expected_result->getProcessedText(), $result->getProcessedText());
$this->assertEquals(CacheableMetadata::createFromObject($expected_result), CacheableMetadata::createFromObject($result));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.