function HalLinkManagerTest::testGetRelationUri

Same name and namespace in other branches
  1. 9 core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetRelationUri()

@covers ::getRelationUri @dataProvider providerTestGetRelationUri @expectedDeprecation The deprecated alter hook hook_rest_relation_uri_alter() is implemented in these functions: hal_test_rest_relation_uri_alter. This hook is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Implement hook_hal_relation_uri_alter() instead.

File

core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php, line 157

Class

HalLinkManagerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21hal%21src%21LinkManager%21LinkManager.php/class/LinkManager/8.9.x" title="LinkManager" class="local">\Drupal\hal\LinkManager\LinkManager</a> @group hal @group legacy

Namespace

Drupal\Tests\hal\Kernel

Code

public function testGetRelationUri($link_domain, $entity_type, $bundle, $field_name, array $context, $expected_return, array $expected_context) {
    $hal_settings = \Drupal::configFactory()->getEditable('hal.settings');
    if ($link_domain === NULL) {
        $hal_settings->clear('link_domain');
    }
    else {
        $hal_settings->set('link_domain', $link_domain)
            ->save(TRUE);
    }
    
    /* @var \Drupal\rest\LinkManager\RelationLinkManagerInterface $relation_manager */
    $relation_manager = \Drupal::service('hal.link_manager.relation');
    $link = $relation_manager->getRelationUri($entity_type, $bundle, $field_name, $context);
    $this->assertSame($link, str_replace('BASE_URL/', Url::fromRoute('<front>', [], [
        'absolute' => TRUE,
    ])->toString(), $expected_return));
    $this->assertEquals($context, $expected_context);
}

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