function ShortcutLinksTest::testShortcutLinkDelete

Same name and namespace in other branches
  1. 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkDelete()
  2. 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testShortcutLinkDelete()
  3. 11.x 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 315

Class

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

Namespace

Drupal\Tests\shortcut\Functional

Code

public function testShortcutLinkDelete() : void {
  $set = $this->set;
  $shortcuts = $set->getShortcuts();
  $shortcut = reset($shortcuts);
  $this->drupalGet('admin/config/user-interface/shortcut/link/' . $shortcut->id() . '/delete');
  $this->submitForm([], '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('');
}

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