class MenuLinkContentDeleteFormTest
Same name and namespace in other branches
- 11.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest
- 10 core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest
- 8.9.x 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 uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\menu_link_content\Functional\MenuLinkContentDeleteFormTest extends \Drupal\Tests\BrowserTestBase
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.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.