Newer
Older
Brian Canini
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
namespace Drupal\Tests\bigmenu\Functional;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\system\Entity\Menu;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the Big Menu interface.
*
* @group bigmenu
*/
class BigMenuUiTest extends BrowserTestBase {
/**
* A user with administration rights.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* A test menu.
*
* @var \Drupal\system\Entity\Menu
*/
protected $menu;
/**
* {@inheritdoc}
*/
protected static $modules = [
'bigmenu',
'menu_link_content',
'menu_ui',
];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer menu']);
$this->menu = Menu::load('main');
}
/**
* Tests the Big Menu interface.
*/
public function testBigMenuUi() {
$this->drupalLogin($this->adminUser);
// Add new menu items in a hierarchy.
$item1 = MenuLinkContent::create([
'title' => 'Item 1',
'link' => [['uri' => 'internal:/']],
'menu_name' => 'main',
]);
$item1->save();
$item1_1 = MenuLinkContent::create([
'title' => 'Item 1 - 1',
'link' => [['uri' => 'internal:/']],
'menu_name' => 'main',
'parent' => 'menu_link_content:' . $item1->uuid(),
]);
$item1_1->save();
$item1_1_1 = MenuLinkContent::create([
'title' => 'Item 1 - 1 - 1',
'link' => [['uri' => 'internal:/']],
'menu_name' => 'main',
'parent' => 'menu_link_content:' . $item1_1->uuid(),
]);
$item1_1_1->save();
$this->drupalGet('admin/structure/menu/manage/main');
$this->assertSession()->linkExistsExact('Item 1');
$this->assertSession()->linkNotExistsExact('Item 1 - 1');
$this->assertSession()->linkNotExistsExact('Item 1 - 1 - 1');
$href = $this->menu->toUrl('edit-form', [
'query' => ['menu_link' => 'menu_link_content:' . $item1->uuid()],
])->toString();
$this->assertSession()->linkByHrefExists($href);
$this->clickLink('Edit child items');
$this->assertSession()->linkExistsExact('Item 1');
$this->assertSession()->linkExistsExact('Item 1 - 1');
$this->assertSession()->linkNotExistsExact('Item 1 - 1 - 1');
$this->clickLink('Edit child items');
$this->assertSession()->linkNotExistsExact('Item 1');
$this->assertSession()->linkExistsExact('Item 1 - 1');
$this->assertSession()->linkExistsExact('Item 1 - 1 - 1');
}
}