MenuLinkDefaultIntegrationTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Menu/MenuLinkDefaultIntegrationTest.php
View source
<?php
namespace Drupal\system\Tests\Menu;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\simpletest\KernelTestBase;
class MenuLinkDefaultIntegrationTest extends KernelTestBase {
public static $modules = array(
'system',
'menu_test',
);
protected function setUp() {
parent::setUp();
$this
->installSchema('system', array(
'router',
));
}
public function testMoveToRoot() {
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$menu_link_manager
->rebuild();
$menu_link = $menu_link_manager
->getDefinition('menu_test.child');
$this
->assertEqual($menu_link['parent'], 'menu_test.parent');
$this
->assertEqual($menu_link['menu_name'], 'test');
$tree = \Drupal::menuTree()
->load('test', new MenuTreeParameters());
$this
->assertEqual(count($tree), 1);
$this
->assertEqual($tree['menu_test.parent']->link
->getPluginId(), 'menu_test.parent');
$this
->assertEqual($tree['menu_test.parent']->subtree['menu_test.child']->link
->getPluginId(), 'menu_test.child');
$menu_link_manager
->updateDefinition('menu_test.child', array(
'parent' => '',
));
$menu_link = $menu_link_manager
->getDefinition('menu_test.child');
$this
->assertEqual($menu_link['parent'], '');
$this
->assertEqual($menu_link['menu_name'], 'test');
$tree = \Drupal::menuTree()
->load('test', new MenuTreeParameters());
$this
->assertEqual(count($tree), 2);
$this
->assertEqual($tree['menu_test.parent']->link
->getPluginId(), 'menu_test.parent');
$this
->assertEqual($tree['menu_test.child']->link
->getPluginId(), 'menu_test.child');
$this
->assertTrue(TRUE);
}
}