You are here

public function ShortcutLinksTest::testAccessShortcutsPermission in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/shortcut/src/Tests/ShortcutLinksTest.php \Drupal\shortcut\Tests\ShortcutLinksTest::testAccessShortcutsPermission()

Tests that the 'access shortcuts' permissions works properly.

File

core/modules/shortcut/src/Tests/ShortcutLinksTest.php, line 306
Contains \Drupal\shortcut\Tests\ShortcutLinksTest.

Class

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

Namespace

Drupal\shortcut\Tests

Code

public function testAccessShortcutsPermission() {

  // Change to a theme that displays shortcuts.
  \Drupal::service('theme_handler')
    ->install(array(
    'seven',
  ));
  $this
    ->config('system.theme')
    ->set('default', 'seven')
    ->save();

  // Add cron to the default shortcut set.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet('admin/config/system/cron');
  $this
    ->clickLink('Add to Default shortcuts');

  // Verify that users without the 'access shortcuts' permission can't see the
  // shortcuts.
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'access toolbar',
  )));
  $this
    ->assertNoLink('Shortcuts', 'Shortcut link not found on page.');

  // Verify that users without the 'administer site configuration' permission
  // can't see the cron shortcuts.
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'access toolbar',
    'access shortcuts',
  )));
  $this
    ->assertNoLink('Shortcuts', 'Shortcut link not found on page.');
  $this
    ->assertNoLink('Cron', 'Cron shortcut link not found on page.');

  // Verify that users with the 'access shortcuts' permission can see the
  // shortcuts.
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'access toolbar',
    'access shortcuts',
    'administer site configuration',
  )));
  $this
    ->clickLink('Shortcuts', 0, 'Shortcut link found on page.');
  $this
    ->assertLink('Cron', 0, 'Cron shortcut link found on page.');
  $this
    ->verifyAccessShortcutsPermissionForEditPages();
}