function HalLinkManagerTest::testGetTypeUri

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

@covers ::getTypeUri @dataProvider providerTestGetTypeUri

File

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

Class

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

Namespace

Drupal\Tests\hal\Kernel

Code

public function testGetTypeUri($link_domain, $entity_type, $bundle, 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\TypeLinkManagerInterface $type_manager */
    $type_manager = \Drupal::service('hal.link_manager.type');
    $link = $type_manager->getTypeUri($entity_type, $bundle, $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.