public function MenuTest::setUp in GraphQL 8.4
Overrides GraphQLTestBase::setUp
File
- tests/
src/ Kernel/ DataProducer/ MenuTest.php, line 26
Class
- MenuTest
- Data producers Menu test class.
Namespace
Drupal\Tests\graphql\Kernel\DataProducerCode
public function setUp() : void {
parent::setUp();
$this
->installEntitySchema('menu_link_content');
$this->menuLinkManager = $this->container
->get('plugin.manager.menu.link');
$this->menu = Menu::create([
'id' => 'menu_test',
'label' => 'Test menu',
'description' => 'Description text',
]);
$this->menu
->save();
$base_options = [
'title' => 'Menu link test',
'provider' => 'graphql',
'menu_name' => 'menu_test',
];
$parent = $base_options + [
'link' => [
'uri' => 'internal:/menu-test/hierarchy/parent',
'options' => [
'attributes' => [
'target' => '_blank',
],
],
],
'description' => 'Test description',
];
$link = MenuLinkContent::create($parent);
$link
->save();
$links['parent'] = $link
->getPluginId();
$this->testLink = $link;
$child_1 = $base_options + [
'link' => [
'uri' => 'internal:/menu-test/hierarchy/parent/child',
],
'parent' => $links['parent'],
];
$link = MenuLinkContent::create($child_1);
$link
->save();
$links['child-1'] = $link
->getPluginId();
$child_1_1 = $base_options + [
'link' => [
'uri' => 'internal:/menu-test/hierarchy/parent/child2/child',
],
'parent' => $links['child-1'],
];
$link = MenuLinkContent::create($child_1_1);
$link
->save();
$links['child-1-1'] = $link
->getPluginId();
$child_1_2 = $base_options + [
'link' => [
'uri' => 'internal:/menu-test/hierarchy/parent/child2/child',
],
'parent' => $links['child-1'],
];
$link = MenuLinkContent::create($child_1_2);
$link
->save();
$links['child-1-2'] = $link
->getPluginId();
$child_2 = $base_options + [
'link' => [
'uri' => 'internal:/menu-test/hierarchy/parent/child',
],
'parent' => $links['parent'],
];
$link = MenuLinkContent::create($child_2);
$link
->save();
$links['child-2'] = $link
->getPluginId();
$this->menuLinkTree = $this->container
->get('menu.link_tree');
$this->linkTree = $this->menuLinkTree
->load('menu_test', new MenuTreeParameters());
}