You are here

public function ShortcutSetsTest::testShortcutSetSwitchOwn in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchOwn()
  2. 10 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchOwn()

Tests switching a user's own shortcut set.

File

core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php, line 108

Class

ShortcutSetsTest
Create, view, edit, delete, and change shortcut sets.

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutSetSwitchOwn() {
  $new_set = $this
    ->generateShortcutSet($this
    ->randomMachineName());

  // Attempt to switch the default shortcut set to the newly created shortcut
  // set.
  $this
    ->drupalPostForm('user/' . $this->adminUser
    ->id() . '/shortcuts', [
    'set' => $new_set
      ->id(),
  ], t('Change set'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $current_set = shortcut_current_displayed_set($this->adminUser);
  $this
    ->assertTrue($new_set
    ->id() == $current_set
    ->id(), 'Successfully switched own shortcut set.');
}