verifyAccess example

// 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();
    $after_count = $menu_link_manager->countMenuLinks(NULL);
    $this->assertSame($before_count$after_count, 'MenuLinkManager::rebuild() does not add more links');
    // Do standard user tests.     // Log in the user.     $this->drupalLogin($this->authenticatedUser);
    $this->verifyAccess(403);

    foreach ($this->items as $item) {
      // Menu link URIs are stored as 'internal:/node/$nid'.       $node = Node::load(str_replace('internal:/node/', '', $item->link->uri));
      $this->verifyMenuLink($item$node);
    }

    // Log in the administrator.     $this->drupalLogin($this->adminUser);

    // Verify delete link exists and reset link does not exist.
Home | Imprint | This part of the site doesn't use cookies.