assertMenuLinkParents example

public function testMenuLinkReparenting($module = 'menu_test') {
    // Check the initial hierarchy.     $links = $this->createLinkHierarchy($module);

    $expected_hierarchy = [
      'parent' => '',
      'child-1' => 'parent',
      'child-1-1' => 'child-1',
      'child-1-2' => 'child-1',
      'child-2' => 'parent',
    ];
    $this->assertMenuLinkParents($links$expected_hierarchy);

    // Start over, and move child-1 under child-2, and check that all the     // children of child-1 have been moved too.     $links = $this->createLinkHierarchy($module);
    $this->menuLinkManager->updateDefinition($links['child-1']['parent' => $links['child-2']]);
    // Verify that the entity was updated too.     /** @var \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin */
    $menu_link_plugin = $this->menuLinkManager->createInstance($links['child-1']);
    $entity = \Drupal::service('entity.repository')->loadEntityByUuid('menu_link_content', $menu_link_plugin->getDerivativeId());
    $this->assertEquals($links['child-2']$entity->getParentId());

    
Home | Imprint | This part of the site doesn't use cookies.