public function MenuUiTest::addCustomMenuCRUD in Drupal 9
Same name and namespace in other branches
- 8 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::addCustomMenuCRUD()
Adds a custom menu using CRUD functions.
1 call to MenuUiTest::addCustomMenuCRUD()
- MenuUiTest::testMenu in core/
modules/ menu_ui/ tests/ src/ Functional/ MenuUiTest.php - Tests menu functionality using the admin and user interfaces.
File
- core/
modules/ menu_ui/ tests/ src/ Functional/ MenuUiTest.php, line 176
Class
- MenuUiTest
- Add a custom menu, add menu links to the custom menu and Tools menu, check their data, and delete them using the UI.
Namespace
Drupal\Tests\menu_ui\FunctionalCode
public function addCustomMenuCRUD() {
// Add a new custom menu.
$menu_name = strtolower($this
->randomMachineName(MenuStorage::MAX_ID_LENGTH));
$label = $this
->randomMachineName(16);
$menu = Menu::create([
'id' => $menu_name,
'label' => $label,
'description' => 'Description text',
]);
$menu
->save();
// Assert the new menu.
$this
->drupalGet('admin/structure/menu/manage/' . $menu_name);
$this
->assertSession()
->pageTextContains($label);
// Edit the menu.
$new_label = $this
->randomMachineName(16);
$menu
->set('label', $new_label);
$menu
->save();
$this
->drupalGet('admin/structure/menu/manage/' . $menu_name);
$this
->assertSession()
->pageTextContains($new_label);
}