addCustomMenu example

protected $defaultTheme = 'stark';

  /** * Tests the contextual links on a menu block. */
  public function testBlockContextualLinks() {
    $this->drupalLogin($this->drupalCreateUser([
      'administer menu',
      'access contextual links',
      'administer blocks',
    ]));
    $menu = $this->addCustomMenu();

    $block = $this->drupalPlaceBlock('system_menu_block:' . $menu->id()[
      'label' => 'Custom menu',
      'provider' => 'system',
    ]);
    $this->addMenuLink('', '/', $menu->id());

    $this->drupalGet('test-page');

    // Click on 'Configure block' contextual link.     $this->clickContextualLink("#block-{$block->id()}", 'Configure block');
    
$this->authenticatedUser = $this->drupalCreateUser([]);
  }

  /** * Tests menu functionality using the admin and user interfaces. */
  public function testMenuAdministration() {
    // Log in the user.     $this->drupalLogin($this->adminUser);
    $this->items = [];

    $this->menu = $this->addCustomMenu();
    $this->doMenuTests();
    $this->doTestMenuBlock();
    $this->addInvalidMenuLink();
    $this->addCustomMenuCRUD();

    // Verify that the menu links rebuild is idempotent and leaves the same     // number of links in the table.     /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    $before_count = $menu_link_manager->countMenuLinks(NULL);
    $menu_link_manager->rebuild();
    
Home | Imprint | This part of the site doesn't use cookies.