public function MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm in Drupal 9
Same name and namespace in other branches
- 8 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]' => t('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.");
}