You are here

public function MenuUiTest::testLogoutLinkVisibility in Drupal 9

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

File

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

Class

MenuUiTest
Add a custom menu, add menu links to the custom menu and Tools menu, check their data, and delete them using the UI.

Namespace

Drupal\Tests\menu_ui\Functional

Code

public function testLogoutLinkVisibility() {
  $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');
}