You are here

public function ShortcutSetsTest::testShortcutSetSwitchOwn in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchOwn()
  2. 9 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 107

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
    ->drupalGet('user/' . $this->adminUser
    ->id() . '/shortcuts');
  $this
    ->submitForm([
    'set' => $new_set
      ->id(),
  ], 'Change set');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $current_set = shortcut_current_displayed_set($this->adminUser);
  $this
    ->assertSame($current_set
    ->id(), $new_set
    ->id(), 'Successfully switched own shortcut set.');
}