function MenuUiTest::verifyAccess

Same name in other branches
  1. 9 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::verifyAccess()
  2. 8.9.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::verifyAccess()
  3. 10 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::testMenuAdministration 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 1133

Class

MenuUiTest
Tests the menu UI.

Namespace

Drupal\Tests\menu_ui\Functional

Code

private function verifyAccess($response = 200) : void {
    // View menu help page.
    $this->drupalGet('admin/help/menu');
    $this->assertSession()
        ->statusCodeEquals($response);
    if ($response == 200) {
        $this->assertSession()
            ->pageTextContains('Menu');
    }
    // View menu build overview page.
    $this->drupalGet('admin/structure/menu');
    $this->assertSession()
        ->statusCodeEquals($response);
    if ($response == 200) {
        $this->assertSession()
            ->pageTextContains('Menus');
    }
    // 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');
    }
    // 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');
    }
    // View add menu page.
    $this->drupalGet('admin/structure/menu/add');
    $this->assertSession()
        ->statusCodeEquals($response);
    if ($response == 200) {
        $this->assertSession()
            ->pageTextContains('Menus');
    }
}

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