Skip to main content

Menus

DrevOps\BehatSteps\Steps\Drupal\MenuTrait - Source, Example, Helpers

Manage Drupal menus and menu links.

  • Create and remove menus by label.
  • Create and remove menu links, including parent-child hierarchies.
  • Created menus and menu links are automatically removed at the end of the scenario.

Prerequisites​

PrerequisiteCapability
A backend in the scenario's list provides "ContentCapabilityInterface"ContentCapabilityInterface
The core "menu_link_content" module is enabled, for the menu link stepsModuleCapabilityInterface

Steps​

@Given the menu :menu_name does not exist

Remove every menu with a label

Given the menu "Test Menu" does not exist
@Given the following menus exist:

Create menus

Given the following menus exist:
| label | description |
| Footer Menu | Links displayed in the footer |
| Secondary Menu | Secondary navigation menu |
@Given the following menu links do not exist in the menu :menu_name:

Remove every menu link with each of the titles

Given the following menu links do not exist in the menu "Main navigation":
| About Us |
| Contact |
@Given the following menu links exist in the menu :menu_name:

Create menu links

Given the following menu links exist in the menu "Main navigation":
| title | enabled | uri | parent |
| Products | 1 | /products | |
| Latest Products | 1 | /products/latest | Products |