function HalLinkManagerTest::testGetRelationUri

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

@covers ::getRelationUri @dataProvider providerTestGetRelationUri

File

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

Class

HalLinkManagerTest
@coversDefaultClass \Drupal\hal\LinkManager\LinkManager @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\hal\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.