public function MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/menu_link_content/src/Tests/MenuLinkContentDeleteFormTest.php \Drupal\menu_link_content\Tests\MenuLinkContentDeleteFormTest::testMenuLinkContentDeleteForm()
Tests the MenuLinkContentDeleteForm class.
File
- core/
modules/ menu_link_content/ src/ Tests/ MenuLinkContentDeleteFormTest.php, line 39 - Contains \Drupal\menu_link_content\Tests\MenuLinkContentDeleteFormTest.
Class
- MenuLinkContentDeleteFormTest
- Tests the menu link content delete UI.
Namespace
Drupal\menu_link_content\TestsCode
public function testMenuLinkContentDeleteForm() {
// Add new menu item.
$this
->drupalPostForm('admin/structure/menu/manage/admin/add', [
'title[0][value]' => t('Front page'),
'link[0][uri]' => '<front>',
], t('Save'));
$this
->assertText(t('The menu link has been saved.'));
$menu_link = MenuLinkContent::load(1);
$this
->drupalGet($menu_link
->urlInfo('delete-form'));
$this
->assertRaw(t('Are you sure you want to delete the custom menu link %name?', [
'%name' => $menu_link
->label(),
]));
$this
->assertLink(t('Cancel'));
// Make sure cancel link points to link edit
$this
->assertLinkByHref($menu_link
->url('edit-form'));
\Drupal::service('module_installer')
->install([
'menu_ui',
]);
// Make sure cancel URL points to menu_ui route now.
$this
->drupalGet($menu_link
->urlInfo('delete-form'));
$menu = Menu::load($menu_link
->getMenuName());
$this
->assertLinkByHref($menu
->url('edit-form'));
$this
->drupalPostForm(NULL, [], t('Delete'));
$this
->assertRaw(t('The menu link %title has been deleted.', [
'%title' => $menu_link
->label(),
]));
}