You are here

private function MenuUiTest::verifyAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::verifyAccess()

Verifies the logged in user has the desired access to various menu pages.

Parameters

int $response: (optional) The expected HTTP response code. Defaults to 200.

1 call to MenuUiTest::verifyAccess()
MenuUiTest::testMenu in core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
Tests menu functionality using the admin and user interfaces.

File

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

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

private function verifyAccess($response = 200) {

  // View menu help page.
  $this
    ->drupalGet('admin/help/menu');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Menu', 'Menu help was displayed');
  }

  // View menu build overview page.
  $this
    ->drupalGet('admin/structure/menu');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Menus', 'Menu build overview page was displayed');
  }

  // View tools menu customization page.
  $this
    ->drupalGet('admin/structure/menu/manage/' . $this->menu
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Tools', 'Tools menu page was displayed');
  }

  // View menu edit page for a static link.
  $item = $this
    ->getStandardMenuLink();
  $this
    ->drupalGet('admin/structure/menu/link/' . $item
    ->getPluginId() . '/edit');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Edit menu item', 'Menu edit page was displayed');
  }

  // View add menu page.
  $this
    ->drupalGet('admin/structure/menu/add');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Menus', 'Add menu page was displayed');
  }
}