You are here

private function MenuUiTest::verifyAccess in Drupal 8

Same name and namespace in other branches
  1. 9 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 948

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
      ->assertText(t('Menu'), 'Menu help was displayed');
  }

  // View menu build overview page.
  $this
    ->drupalGet('admin/structure/menu');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertText(t('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
      ->assertText(t('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
      ->assertText(t('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
      ->assertText(t('Menus'), 'Add menu page was displayed');
  }
}