function LinksetControllerTest::testCustomLinkRelation

Same name in other branches
  1. 11.x core/modules/system/tests/src/Functional/Menu/LinksetControllerTest.php \Drupal\Tests\system\Functional\Menu\LinksetControllerTest::testCustomLinkRelation()

Tests that menu items can use a custom link relation.

File

core/modules/system/tests/src/Functional/Menu/LinksetControllerTest.php, line 316

Class

LinksetControllerTest
Tests the behavior of the linkset controller.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testCustomLinkRelation() : void {
    $this->enableEndpoint(TRUE);
    $this->assertTrue($this->container
        ->get('module_installer')
        ->install([
        'decoupled_menus_test',
    ], TRUE), 'Installed modules.');
    $response = $this->doRequest('GET', Url::fromUri('base:/system/menu/account/linkset'), 200, $this->authorAccount);
    $link_context_object = Json::decode((string) $response->getBody())['linkset'][0];
    $this->assertContains('authenticated-as', array_keys($link_context_object));
    $my_account_link = $link_context_object['authenticated-as'][0];
    $this->assertSame('My account', $my_account_link['title']);
}

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