function ShortcutSetsTest::testShortcutSetUnassignOnUserRemoval

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

Tests assign clearing on user removal.

File

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

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutSetUnassignOnUserRemoval() : void {
    $new_set = $this->generateShortcutSet($this->randomMachineName());
    $shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set');
    $shortcut_set_storage->assignUser($new_set, $this->shortcutUser);
    $this->shortcutUser
        ->delete();
    $current_set = $shortcut_set_storage->getDisplayedToUser($this->shortcutUser);
    $default_set = $shortcut_set_storage->getDefaultSet($this->shortcutUser);
    $this->assertSame($default_set->id(), $current_set->id(), "Successfully cleared assigned shortcut set for removed user.");
}

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