class MenuLinkContentDeleteFormTest in Drupal 10
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
- 9 core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest
Tests the menu link content delete UI.
@group Menu
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest
Expanded class hierarchy of MenuLinkContentDeleteFormTest
File
- core/
modules/ menu_link_content/ tests/ src/ Functional/ MenuLinkContentDeleteFormTest.php, line 14
Namespace
Drupal\Tests\menu_link_content\FunctionalView source
class MenuLinkContentDeleteFormTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'menu_link_content',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$web_user = $this
->drupalCreateUser([
'administer menu',
]);
$this
->drupalLogin($web_user);
}
/**
* Tests the MenuLinkContentDeleteForm class.
*/
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.");
}
}