function ShortcutSetsTest::testShortcutSetSwitchCreate

Same name in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchCreate()
  2. 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchCreate()
  3. 10 core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php \Drupal\Tests\shortcut\Functional\ShortcutSetsTest::testShortcutSetSwitchCreate()

Tests switching a user's shortcut set and creating one at the same time.

File

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

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutSetSwitchCreate() : void {
    $edit = [
        'set' => 'new',
        'id' => $this->randomMachineName(),
        'label' => $this->randomString(),
    ];
    $this->drupalGet('user/' . $this->adminUser
        ->id() . '/shortcuts');
    $this->submitForm($edit, 'Change set');
    $shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set');
    $current_set = $shortcut_set_storage->getDisplayedToUser($this->adminUser);
    $this->assertNotEquals($this->set
        ->id(), $current_set->id(), 'A shortcut set can be switched to at the same time as it is created.');
    $this->assertEquals($edit['label'], $current_set->label(), 'The new set is correctly assigned to the user.');
}

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