function ShortcutSetsTest::testShortcutSetSwitchOwn

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

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutSetSwitchOwn() : void {
    $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);
    $shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set');
    $current_set = $shortcut_set_storage->getDisplayedToUser($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.