function ShortcutSetsTest::testShortcutSetSwitchOwn

Same name and namespace in other branches
  1. 8.9.x 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()
  3. 11.x 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.');
}

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