MenuLinkContentDeleteFormTest.php in Zircon Profile 8
File
core/modules/menu_link_content/src/Tests/MenuLinkContentDeleteFormTest.php
View source
<?php
namespace Drupal\menu_link_content\Tests;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\simpletest\WebTestBase;
use Drupal\system\Entity\Menu;
class MenuLinkContentDeleteFormTest extends WebTestBase {
public static $modules = [
'menu_link_content',
];
protected function setUp() {
parent::setUp();
$web_user = $this
->drupalCreateUser([
'administer menu',
]);
$this
->drupalLogin($web_user);
}
public function testMenuLinkContentDeleteForm() {
$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'));
$this
->assertLinkByHref($menu_link
->url('edit-form'));
\Drupal::service('module_installer')
->install([
'menu_ui',
]);
$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(),
]));
}
}