function MenuUiTest::testLogoutLinkVisibility

Same name in other branches
  1. 9 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testLogoutLinkVisibility()
  2. 10 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::testLogoutLinkVisibility()

Test logout link isn't displayed when the user is logged out.

File

core/modules/menu_ui/tests/src/Functional/MenuUiTest.php, line 615

Class

MenuUiTest
Tests the menu UI.

Namespace

Drupal\Tests\menu_ui\Functional

Code

public function testLogoutLinkVisibility() : void {
    $adminUserWithLinkAnyPage = $this->drupalCreateUser([
        'access administration pages',
        'administer blocks',
        'administer menu',
        'create article content',
        'link to any page',
    ]);
    $this->drupalLogin($adminUserWithLinkAnyPage);
    $this->addMenuLink('', '/user/logout', 'main');
    $assert = $this->assertSession();
    // Verify that any link with logout URL is displayed.
    $assert->linkByHrefExists('user/logout');
    // Verify that any link with logout URL is not displayed.
    $this->drupalLogout();
    $assert->linkByHrefNotExists('user/logout');
}

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