You are here

private function ShortcutLinksTest::verifyAccessShortcutsPermissionForEditPages in Drupal 9

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

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);
}