function MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm
Same name in other branches
- 8.9.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm()
- 10 core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm()
- 11.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm()
Tests the MenuLinkContentDeleteForm class.
File
-
core/
modules/ menu_link_content/ tests/ src/ Functional/ MenuLinkContentDeleteFormTest.php, line 40
Class
- MenuLinkContentDeleteFormTest
- Tests the menu link content delete UI.
Namespace
Drupal\Tests\menu_link_content\FunctionalCode
public function testMenuLinkContentDeleteForm() {
// Add new menu item.
$this->drupalGet('admin/structure/menu/manage/admin/add');
$this->submitForm([
'title[0][value]' => 'Front page',
'link[0][uri]' => '<front>',
], 'Save');
$this->assertSession()
->pageTextContains('The menu link has been saved.');
$menu_link = MenuLinkContent::load(1);
$this->drupalGet($menu_link->toUrl('delete-form'));
$this->assertSession()
->pageTextContains("Are you sure you want to delete the custom menu link {$menu_link->label()}?");
$this->assertSession()
->linkExists('Cancel');
// Make sure cancel link points to link edit
$this->assertSession()
->linkByHrefExists($menu_link->toUrl('edit-form')
->toString());
\Drupal::service('module_installer')->install([
'menu_ui',
]);
// Make sure cancel URL points to menu_ui route now.
$this->drupalGet($menu_link->toUrl('delete-form'));
$menu = Menu::load($menu_link->getMenuName());
$this->assertSession()
->linkByHrefExists($menu->toUrl('edit-form')
->toString());
$this->submitForm([], 'Delete');
$this->assertSession()
->pageTextContains("The menu link {$menu_link->label()} has been deleted.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.