public function HalLinkManagerTest::testHalLinkManagersSetLinkDomain in Drupal 9
Same name and namespace in other branches
- 8 core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testHalLinkManagersSetLinkDomain()
@covers ::setLinkDomain
File
- core/
modules/ hal/ tests/ src/ Kernel/ HalLinkManagerTest.php, line 240
Class
- HalLinkManagerTest
- @coversDefaultClass \Drupal\hal\LinkManager\LinkManager @group hal
Namespace
Drupal\Tests\hal\KernelCode
public function testHalLinkManagersSetLinkDomain() {
$serialization_context = [
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY => new CacheableMetadata(),
];
/** @var \Drupal\hal\LinkManager\LinkManager $link_manager */
$link_manager = \Drupal::service('hal.link_manager');
$link_manager
->setLinkDomain('http://example.com/');
$link = $link_manager
->getTypeUri('node', 'page', $serialization_context);
$this
->assertEquals('http://example.com/rest/type/node/page', $link);
$this
->assertEquals($serialization_context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY], new CacheableMetadata());
$link = $link_manager
->getRelationUri('node', 'page', 'field_ref', $serialization_context);
$this
->assertEquals('http://example.com/rest/relation/node/page/field_ref', $link);
$this
->assertEquals($serialization_context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY], new CacheableMetadata());
}