protected function MenuLinkWeightTest::setUp in Menu Link Weight 7
Same name and namespace in other branches
- 8.2 menu_link_weight.test \MenuLinkWeightTest::setUp()
- 8 menu_link_weight.test \MenuLinkWeightTest::setUp()
Set up.
Overrides DrupalWebTestCase::setUp
File
- ./
menu_link_weight.test, line 27 - Web tests for Menu Link Weight.
Class
- MenuLinkWeightTest
- Test class for Menu Link Weight.
Code
protected function setUp() {
parent::setUp('menu_link_weight');
$permissions = array(
'access administration pages',
'administer content types',
'administer blocks',
'administer menu',
'administer taxonomy',
'create page content',
'edit any page content',
'delete any page content',
'create article content',
);
// Create user.
$this->user = $this
->drupalCreateUser($permissions);
// Log in user.
$this
->drupalLogin($this->user);
// Create a new menu.
$title = $this
->randomName(16);
$menu_name = substr(hash('sha256', $this
->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
$edit = array(
'menu_name' => $menu_name,
'description' => '',
'title' => $title,
);
// Drupal prepends the menu name with "menu-".
$this->menu_name = 'menu-' . $menu_name;
$this
->drupalPost('admin/structure/menu/add', $edit, t('Save'));
$this
->drupalGet('admin/structure/menu');
$this
->assertText($title, 'Menu created');
// Enable the custom menu block.
$edit = array();
$edit['blocks[menu_' . $this->menu_name . '][region]'] = 'sidebar_first';
$this
->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this
->assertResponse(200);
$this
->assertText(t('The block settings have been updated.'), 'Custom menu block was enabled');
}