function HalLinkManagerTest::testHalLinkManagersSetLinkDomain

Same name in other branches
  1. 9 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 270

Class

HalLinkManagerTest
@coversDefaultClass \Drupal\hal\LinkManager\LinkManager @group hal @group legacy

Namespace

Drupal\Tests\hal\Kernel

Code

public function testHalLinkManagersSetLinkDomain() {
    $serialization_context = [
        CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY => new CacheableMetadata(),
    ];
    
    /* @var \Drupal\rest\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->assertEqual($link, 'http://example.com/rest/type/node/page');
    $this->assertEqual(new CacheableMetadata(), $serialization_context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]);
    $link = $link_manager->getRelationUri('node', 'page', 'field_ref', $serialization_context);
    $this->assertEqual($link, 'http://example.com/rest/relation/node/page/field_ref');
    $this->assertEqual(new CacheableMetadata(), $serialization_context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]);
}

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