function ShortcutLinksTest::verifyAccessShortcutsPermissionForEditPages

Same name in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::verifyAccessShortcutsPermissionForEditPages()
  2. 10 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::verifyAccessShortcutsPermissionForEditPages()
  3. 11.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::verifyAccessShortcutsPermissionForEditPages()

Tests that the 'access shortcuts' permission is required for shortcut set administration page access.

1 call to ShortcutLinksTest::verifyAccessShortcutsPermissionForEditPages()
ShortcutLinksTest::testAccessShortcutsPermission in core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php
Tests that the 'access shortcuts' permissions works properly.

File

core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php, line 405

Class

ShortcutLinksTest
Create, view, edit, delete, and change shortcut links.

Namespace

Drupal\Tests\shortcut\Functional

Code

private function verifyAccessShortcutsPermissionForEditPages() {
    // Create a user with customize links and switch sets permissions  but
    // without the 'access shortcuts' permission.
    $test_permissions = [
        'customize shortcut links',
        'switch shortcut sets',
    ];
    $noaccess_user = $this->drupalCreateUser($test_permissions);
    $this->drupalLogin($noaccess_user);
    // Verify that set administration pages are inaccessible without the
    // 'access shortcuts' permission.
    $this->drupalGet('admin/config/user-interface/shortcut/manage/default/customize');
    $this->assertSession()
        ->statusCodeEquals(403);
    $this->drupalGet('admin/config/user-interface/shortcut/manage/default');
    $this->assertSession()
        ->statusCodeEquals(403);
    $this->drupalGet('user/' . $noaccess_user->id() . '/shortcuts');
    $this->assertSession()
        ->statusCodeEquals(403);
}

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