You are here

public function ShortcutLinksTest::testShortcutLinkDelete in Drupal 8

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

Tests deleting a shortcut link.

File

core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php, line 285

Class

ShortcutLinksTest
Create, view, edit, delete, and change shortcut links.

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutLinkDelete() {
  $set = $this->set;
  $shortcuts = $set
    ->getShortcuts();
  $shortcut = reset($shortcuts);
  $this
    ->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut
    ->id() . '/delete', [], 'Delete');
  $saved_set = ShortcutSet::load($set
    ->id());
  $ids = $this
    ->getShortcutInformation($saved_set, 'id');
  $this
    ->assertNotContains($shortcut
    ->id(), $ids, 'Successfully deleted a shortcut.');

  // Delete all the remaining shortcut links.
  $storage = \Drupal::entityTypeManager()
    ->getStorage('shortcut');
  $storage
    ->delete($storage
    ->loadMultiple(array_filter($ids)));

  // Get the front page to check that no exceptions occur.
  $this
    ->drupalGet('');
}