- <?php
- * @file
- * Tests for menu.module.
- */
-
- class MenuTestCase extends BackdropWebTestCase {
- protected $big_user;
- protected $std_user;
- protected $menu;
- protected $items;
-
- function setUp() {
- parent::setUp('menu');
-
- $this->big_user = $this->backdropCreateUser(array('access administration pages', 'administer blocks', 'administer menu', 'create post content'));
- $this->std_user = $this->backdropCreateUser(array());
-
-
- $layout = layout_load('default');
-
- $menu_uuid = $layout->positions['header'][1];
- $menu_block = $layout->content[$menu_uuid];
-
-
- $menu_block->settings['block_settings']['level'] = 1;
- $menu_block->settings['block_settings']['depth'] = 0;
-
-
- $layout->save();
- }
-
-
- * Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.
- */
- function testMenu() {
-
- $this->backdropLogin($this->big_user);
- $this->items = array();
-
-
- $layout = layout_load('default');
- $layout->addBlock('system', 'main-menu', 'sidebar');
- $layout->save();
-
-
- $this->doStandardMenuTests();
-
-
- $this->doCustomMenuTests();
-
-
-
- $this->backdropLogin($this->std_user);
- $this->verifyAccess(403);
- foreach ($this->items as $item) {
- $node = node_load(substr($item['link_path'], 5));
- $this->verifyMenuLink($item, $node);
- }
-
-
- $this->backdropLogin($this->big_user);
-
-
- foreach ($this->items as $item) {
- $this->deleteMenuLink($item);
- }
-
-
- $this->deleteCustomMenu($this->menu);
-
-
- $item = $this->getStandardMenuLink();
- $old_title = $item['link_title'];
- $this->modifyMenuLink($item);
- $item = menu_link_load($item['mlid']);
-
- $description = $this->randomName(16);
- $item['options']['attributes']['title'] = $description;
- menu_link_save($item);
- $saved_item = menu_link_load($item['mlid']);
- $this->assertEqual($description, $saved_item['options']['attributes']['title'], 'Saving an existing link updates the description (title attribute)');
- $this->resetMenuLink($item, $old_title);
-
-
- config_set('system.core', 'user_register', USER_REGISTER_VISITORS);
- $this->addMenuLink(0, 'user/register', 'user-menu');
- $this->backdropLogout();
- $this->backdropGet('user/register');
- $this->assertTitle('Create new account | Backdrop CMS');
- $this->backdropGet('user/password');
- $this->assertTitle('Reset password | Backdrop CMS');
- $this->backdropGet('user/login');
- $this->assertTitle('Log in | Backdrop CMS');
- $this->backdropGet('user');
- $this->assertTitle('Log in | Backdrop CMS');
- }
-
-
- * Test standard menu functionality using main-menu menu.
- *
- */
- function doStandardMenuTests() {
- $this->doMenuTests();
- $this->addInvalidMenuLink();
- }
-
-
- * Test custom menu functionality using main-menu menu.
- *
- */
- function doCustomMenuTests() {
- $this->menu = $this->addCustomMenu();
- $this->doMenuTests($this->menu['menu_name']);
- $this->addInvalidMenuLink($this->menu['menu_name']);
- $this->addCustomMenuCRUD();
- }
-
-
- * Add custom menu using CRUD functions.
- */
- function addCustomMenuCRUD() {
-
- $menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
- $title = $this->randomName(16);
-
- $menu = array(
- 'menu_name' => $menu_name,
- 'title' => $title,
- 'description' => 'Description text',
- );
- menu_save($menu);
-
-
- $this->backdropGet('admin/structure/menu/manage/' . $menu_name . '/edit');
- $this->assertRaw($title, 'Custom menu was added.');
-
-
- $new_title = $this->randomName(16);
- $menu['title'] = $new_title;
- menu_save($menu);
- $this->backdropGet('admin/structure/menu/manage/' . $menu_name . '/edit');
- $this->assertRaw($new_title, 'Custom menu was edited.');
- }
-
-
- * Add custom menu.
- */
- function addCustomMenu() {
-
-
-
- $this->backdropGet('admin/structure/menu/add');
- $menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI + 1);
- $title = $this->randomName(16);
- $edit = array(
- 'menu_name' => $menu_name,
- 'description' => '',
- 'title' => $title,
- );
- $this->backdropPost('admin/structure/menu/add', $edit, t('Save'));
-
-
- $this->assertRaw(t('!name cannot be longer than %max characters but is currently %length characters long.', array(
- '!name' => t('Menu name'),
- '%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
- '%length' => backdrop_strlen($menu_name),
- )));
-
-
- $menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
- $edit['menu_name'] = $menu_name;
- $this->backdropPost('admin/structure/menu/add', $edit, t('Save'));
-
-
- $this->assertNoRaw(t('!name cannot be longer than %max characters but is currently %length characters long.', array(
- '!name' => t('Menu name'),
- '%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
- '%length' => backdrop_strlen($menu_name),
- )));
-
-
- $this->backdropGet('admin/structure/menu');
- $this->assertText($title, 'Menu created');
-
-
- $menu_name = 'menu-' . $menu_name;
- $layout = layout_load('default');
- $layout->addBlock('menu', $menu_name, 'sidebar');
- $layout->save();
-
- backdrop_static_reset();
- return menu_load($menu_name);
- }
-
-
- * Delete custom menu.
- *
- * @param string $menu_name Custom menu name.
- */
- function deleteCustomMenu($menu) {
- $menu_name = $this->menu['menu_name'];
- $title = $this->menu['title'];
-
-
- $this->backdropPost("admin/structure/menu/manage/$menu_name/delete", array(), t('Delete'));
- $this->assertResponse(200);
- $this->assertRaw(t('The custom menu %title has been deleted.', array('%title' => $title)), 'Custom menu was deleted');
- $this->assertFalse(menu_load($menu_name), 'Custom menu was deleted');
-
- $result = db_query("SELECT menu_name FROM {menu_links} WHERE menu_name = :menu_name", array(':menu_name' => $menu_name))->fetchField();
- $this->assertFalse($result, 'All menu links associated to the custom menu were deleted.');
- }
-
-
- * Test menu functionality using main-menu menu.
- */
- function doMenuTests($menu_name = 'main-menu') {
-
- $node1 = $this->backdropCreateNode(array('type' => 'post'));
- $node2 = $this->backdropCreateNode(array('type' => 'post'));
- $node3 = $this->backdropCreateNode(array('type' => 'post'));
- $node4 = $this->backdropCreateNode(array('type' => 'post'));
- $node5 = $this->backdropCreateNode(array('type' => 'post'));
-
-
- $item1 = $this->addMenuLink(0, 'node/' . $node1->nid, $menu_name);
- $item2 = $this->addMenuLink($item1['mlid'], 'node/' . $node2->nid, $menu_name, FALSE);
- $item3 = $this->addMenuLink($item2['mlid'], 'node/' . $node3->nid, $menu_name);
- $this->assertMenuLink($item1['mlid'], array('depth' => 1, 'has_children' => 1, 'p1' => $item1['mlid'], 'p2' => 0));
- $this->assertMenuLink($item2['mlid'], array('depth' => 2, 'has_children' => 1, 'p1' => $item1['mlid'], 'p2' => $item2['mlid'], 'p3' => 0));
- $this->assertMenuLink($item3['mlid'], array('depth' => 3, 'has_children' => 0, 'p1' => $item1['mlid'], 'p2' => $item2['mlid'], 'p3' => $item3['mlid'], 'p4' => 0));
-
-
- $items = array();
- for ($i = -51; $i <= 51; $i++) {
- $items[$i] = $this->addMenuLink(0, 'node/' . $node1->nid, $menu_name, TRUE, strval($i));
- }
-
-
- $this->assertMenuLink($items[-51]['mlid'], array('weight' => '-51'));
- $this->assertMenuLink($items[51]['mlid'], array('weight' => '51'));
-
-
- $this->verifyMenuLink($item1, $node1);
- $this->verifyMenuLink($item2, $node2, $item1, $node1);
- $this->verifyMenuLink($item3, $node3, $item2, $node2);
-
-
- $item4 = $this->addMenuLink(0, 'node/' . $node4->nid, $menu_name);
- $item5 = $this->addMenuLink($item4['mlid'], 'node/' . $node5->nid, $menu_name);
- $this->assertMenuLink($item4['mlid'], array('depth' => 1, 'has_children' => 1, 'p1' => $item4['mlid'], 'p2' => 0));
- $this->assertMenuLink($item5['mlid'], array('depth' => 2, 'has_children' => 0, 'p1' => $item4['mlid'], 'p2' => $item5['mlid'], 'p3' => 0));
-
-
- $node4->path = array(
- 'pid' => NULL,
- 'source' => 'node/' . $node4->nid,
- 'alias' => 'node' . $node4->nid . '-alias',
- 'langcode' => LANGUAGE_NONE,
- 'auto' => FALSE,
- );
- $node4->save();
-
- $item6 = $this->addMenuLink(0, 'node' . $node4->nid . '-alias', $menu_name);
- $this->assertMenuLink($item6['mlid'], array('link_path' => 'node/' . $node4->nid));
-
-
- $this->backdropGet('admin/structure/menu/item/' . $item6['mlid'] . '/edit');
- $this->assertFieldByXPath('//input[@name="link_path"]', 'node' . $node4->nid . '-alias');
-
-
- $this->modifyMenuLink($item1);
- $this->modifyMenuLink($item2);
-
-
- $this->toggleMenuLink($item1);
- $this->toggleMenuLink($item2);
-
-
- $this->moveMenuLink($item2, $item5['mlid'], $menu_name);
- $this->assertMenuLink($item1['mlid'], array('depth' => 1, 'has_children' => 0, 'p1' => $item1['mlid'], 'p2' => 0));
- $this->assertMenuLink($item4['mlid'], array('depth' => 1, 'has_children' => 1, 'p1' => $item4['mlid'], 'p2' => 0));
- $this->assertMenuLink($item5['mlid'], array('depth' => 2, 'has_children' => 1, 'p1' => $item4['mlid'], 'p2' => $item5['mlid'], 'p3' => 0));
- $this->assertMenuLink($item2['mlid'], array('depth' => 3, 'has_children' => 1, 'p1' => $item4['mlid'], 'p2' => $item5['mlid'], 'p3' => $item2['mlid'], 'p4' => 0));
- $this->assertMenuLink($item3['mlid'], array('depth' => 4, 'has_children' => 0, 'p1' => $item4['mlid'], 'p2' => $item5['mlid'], 'p3' => $item2['mlid'], 'p4' => $item3['mlid'], 'p5' => 0));
-
-
- $this->disableMenuLink($item1);
- $edit = array();
-
-
-
- $edit['mlid:' . $item1['mlid'] . '[hidden]'] = TRUE;
- $this->backdropPost('admin/structure/menu/manage/' . $item1['menu_name'], $edit, t('Save configuration'));
-
-
- $this->assertMenuLink($item1['mlid'], array('hidden' => 0));
-
-
- $this->items[] = $item1;
- $this->items[] = $item2;
- }
-
-
- * Add and remove a menu link with a query string and fragment.
- */
- function testMenuQueryAndFragment() {
- $this->backdropLogin($this->big_user);
-
-
- $path = 'node?arg1=value1&arg2=value2';
- $item = $this->addMenuLink(0, $path);
-
- $this->backdropGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
- $this->assertFieldByName('link_path', $path, 'Path is found with both query and fragment.');
-
-
- $path = 'node';
- $this->backdropPost('admin/structure/menu/item/' . $item['mlid'] . '/edit', array('link_path' => $path), t('Save'));
- $this->backdropGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
- $this->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.');
- }
-
-
- * Add a menu link using the menu module UI.
- *
- * @param integer $plid
- * Parent menu link ID.
- * @param string $link
- * Link path.
- * @param string $menu_name
- * Menu name.
- * @param int $weight
- * Menu link weight.
- *
- * @return array
- * Menu link created.
- */
- function addMenuLink($plid = 0, $link = '<front>', $menu_name = 'main-menu', $expanded = TRUE, $weight = 0) {
-
- $this->backdropGet("admin/structure/menu/manage/$menu_name/add");
- $this->assertResponse(200);
-
- $title = '!link_' . $this->randomName(16);
- $edit = array(
- 'link_path' => $link,
- 'link_title' => $title,
- 'description' => '',
- 'enabled' => TRUE,
- 'expanded' => $expanded,
- 'parent' => $menu_name . ':' . $plid,
- 'weight' => $weight,
- );
-
-
- $this->backdropPost(NULL, $edit, t('Save'));
- $this->assertResponse(200);
-
- $this->assertText($title, 'Menu link was added');
-
-
- $source = backdrop_lookup_path('source', $link);
- if (empty($source)) {
- $source = $link;
- }
-
- $item = db_query('SELECT * FROM {menu_links} WHERE link_title = :title', array(':title' => $title))->fetchAssoc();
- $this->assertTrue(t('Menu link was found in database.'));
- $this->assertMenuLink($item['mlid'], array('menu_name' => $menu_name, 'link_path' => $source, 'has_children' => 0, 'plid' => $plid));
-
- return $item;
- }
-
-
- * Attempt to add menu link with invalid path or no access permission.
- *
- * @param string $menu_name Menu name.
- */
- function addInvalidMenuLink($menu_name = 'main-menu') {
- foreach (array('-&-', 'admin/config/people/permissions', '#') as $link_path) {
- $edit = array(
- 'link_path' => $link_path,
- 'link_title' => 'title',
- );
- $this->backdropPost("admin/structure/menu/manage/$menu_name/add", $edit, t('Save'));
- $this->assertRaw(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $link_path)), 'Menu link was not created');
- }
- }
-
-
- * Verify a menu link using the menu module UI.
- *
- * @param array $item Menu link.
- * @param object $item_node Menu link content node.
- * @param array $parent Parent menu link.
- * @param object $parent_node Parent menu link content node.
- */
- function verifyMenuLink($item, $item_node, $parent = NULL, $parent_node = NULL) {
-
- $this->backdropGet('user');
- $this->assertResponse(200);
-
-
- if (isset($parent)) {
-
- $title = $parent['link_title'];
- $this->assertLink($title, 0, 'Parent menu link was displayed');
-
-
- $this->clickLink($title);
- $title = $parent_node->title;
- $this->assertTitle(t("@title | Backdrop CMS", array('@title' => $title)), 'Parent menu link link target was correct');
- }
-
-
- $title = $item['link_title'];
- $this->assertLink($title, 0, 'Menu link was displayed');
-
-
- $this->clickLink($title);
- $title = $item_node->title;
- $this->assertTitle(t("@title | Backdrop CMS", array('@title' => $title)), 'Menu link link target was correct');
- }
-
-
- * Change the parent of a menu link using the menu module UI.
- */
- function moveMenuLink($item, $plid, $menu_name) {
- $mlid = $item['mlid'];
-
- $edit = array(
- 'parent' => $menu_name . ':' . $plid,
- );
- $this->backdropPost("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
- $this->assertResponse(200);
- }
-
-
- * Modify a menu link using the menu module UI.
- *
- * @param array $item Menu link passed by reference.
- */
- function modifyMenuLink(&$item) {
- $item['link_title'] = $this->randomName(16);
-
- $mlid = $item['mlid'];
- $title = $item['link_title'];
-
-
- $edit = array();
- $edit['link_title'] = $title;
- $this->backdropPost("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
- $this->assertResponse(200);
-
-
-
- $this->backdropGet('admin/structure/menu/manage/' . $item['menu_name']);
- $this->assertText($title, 'Menu link was edited');
- }
-
-
- * Reset a standard menu link using the menu module UI.
- *
- * @param array $item Menu link.
- * @param string $old_title Original title for menu link.
- */
- function resetMenuLink($item, $old_title) {
- $mlid = $item['mlid'];
- $title = $item['link_title'];
-
-
- $this->backdropPost("admin/structure/menu/item/$mlid/reset", array(), t('Reset'));
- $this->assertResponse(200);
- $this->assertRaw(t('The menu link was reset to its default settings.'), 'Menu link was reset');
-
-
- $this->backdropGet('');
- $this->assertNoText($title, 'Menu link was reset');
- $this->assertText($old_title, 'Menu link was reset');
- }
-
-
- * Delete a menu link using the menu module UI.
- *
- * @param array $item Menu link.
- */
- function deleteMenuLink($item) {
- $mlid = $item['mlid'];
- $title = $item['link_title'];
-
-
- $this->backdropPost("admin/structure/menu/item/$mlid/delete", array(), t('Confirm'));
- $this->assertResponse(200);
- $this->assertRaw(t('The menu link %title has been deleted.', array('%title' => $title)), 'Menu link was deleted');
-
-
- $this->backdropGet('user');
- $this->assertNoText($title, 'Menu link was deleted');
- }
-
-
- * Alternately disable and enable a menu link.
- *
- * @param $item
- * Menu link.
- */
- function toggleMenuLink($item) {
- $this->disableMenuLink($item);
-
- $this->backdropGet('user');
- $this->assertNoText($item['link_title'], 'Menu link was not displayed');
-
- $this->enableMenuLink($item);
-
- $this->backdropGet('user');
- $this->assertText($item['link_title'], 'Menu link was displayed');
- }
-
-
- * Disable a menu link.
- *
- * @param $item
- * Menu link.
- */
- function disableMenuLink($item) {
- $mlid = $item['mlid'];
- $edit['enabled'] = FALSE;
- $this->backdropPost("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
-
-
-
- $this->assertMenuLink($mlid, array('hidden' => 1));
- }
-
-
- * Enable a menu link.
- *
- * @param $item
- * Menu link.
- */
- function enableMenuLink($item) {
- $mlid = $item['mlid'];
- $edit['enabled'] = TRUE;
- $this->backdropPost("admin/structure/menu/item/$mlid/edit", $edit, t('Save'));
-
-
- $this->assertMenuLink($mlid, array('hidden' => 0));
- }
-
-
- * Fetch the menu item from the database and compare it to the specified
- * array.
- *
- * @param $mlid
- * Menu item id.
- * @param $item
- * Array containing properties to verify.
- */
- function assertMenuLink($mlid, array $expected_item) {
-
- $item = db_query('SELECT * FROM {menu_links} WHERE mlid = :mlid', array(':mlid' => $mlid))->fetchAssoc();
- $options = unserialize($item['options']);
- if (!empty($options['query'])) {
- $item['link_path'] .= '?' . backdrop_http_build_query($options['query']);
- }
- if (!empty($options['fragment'])) {
- $item['link_path'] .= '#' . $options['fragment'];
- }
- foreach ($expected_item as $key => $value) {
- $this->assertEqual($item[$key], $value, format_string('Parameter %key had value %actual, expected %expected for the %path path.', array('%key' => $key, '%path' => $item['link_path'], '%actual' => $item[$key], '%expected' => $value)));
- }
- }
-
-
- * Test administrative users other than user 1 can access the menu parents AJAX callback.
- */
- public function testMenuParentsJsAccess() {
- $admin = $this->backdropCreateUser(array('administer menu'));
- $this->backdropLogin($admin);
-
- $this->backdropGet('admin/structure/menu/parents');
- $this->assertResponse(200);
-
-
- $this->backdropLogin($this->std_user);
- $this->backdropGet('admin/structure/menu/parents');
- $this->assertResponse(403);
- }
-
-
- * Get standard menu link.
- */
- private function getStandardMenuLink() {
-
- $mlid = db_query("SELECT mlid FROM {menu_links} WHERE module = 'system' AND router_path = 'user/logout'")->fetchField();
- $this->assertTrue($mlid > 0, 'Standard menu link id was found');
-
-
- $item = menu_link_load($mlid);
- $this->assertTrue((bool) $item, 'Standard menu link was loaded');
- return $item;
- }
-
-
- * Verify the logged in user has the desired access to the various menu nodes.
- *
- * @param integer $response HTTP response code.
- */
- private function verifyAccess($response = 200) {
-
- $this->backdropGet('admin/help/menu');
- $this->assertResponse($response);
- if ($response == 200) {
- $this->assertText(t('Menu'), 'Menu help was displayed');
- }
-
-
- $this->backdropGet('admin/structure/menu');
- $this->assertResponse($response);
- if ($response == 200) {
- $this->assertText(t('Menus'), 'Menu build overview node was displayed');
- }
-
-
- $this->backdropGet('admin/structure/menu/manage/main-menu');
- $this->assertResponse($response);
- if ($response == 200) {
- $this->assertText(t('Primary navigation'), 'Primary navigation menu node was displayed');
- }
-
-
- $item = $this->getStandardMenuLink();
- $this->backdropGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
- $this->assertResponse($response);
- if ($response == 200) {
- $this->assertText(t('Edit menu item'), 'Menu edit node was displayed');
- }
-
-
- $this->backdropGet('admin/structure/menu/settings');
- $this->assertResponse($response);
- if ($response == 200) {
- $this->assertText(t('Menus'), 'Menu settings node was displayed');
- }
-
-
- $this->backdropGet('admin/structure/menu/add');
- $this->assertResponse($response);
- if ($response == 200) {
- $this->assertText(t('Menus'), 'Add menu node was displayed');
- }
- }
- }
-
- * Test menu settings for nodes.
- */
- class MenuNodeTestCase extends BackdropWebTestCase {
-
-
- * @var User
- */
- protected $admin_user;
-
- function setUp() {
- parent::setUp('menu');
-
- $this->admin_user = $this->backdropCreateUser(array(
- 'access administration pages',
- 'administer content types',
- 'administer menu',
- 'create page content',
- 'edit any page content',
- 'delete any page content',
- ));
- $this->backdropLogin($this->admin_user);
- }
-
-
- * Test creating, editing, deleting menu links via node form widget.
- */
- function testMenuNodeFormWidget() {
-
- $edit = array(
- 'menu_options[main-menu]' => 1,
- );
- $this->backdropPost('admin/structure/types/manage/page', $edit, t('Save content type'));
-
-
- $edit = array(
- 'menu_parent' => 'main-menu:0',
- );
- $this->backdropPost('admin/structure/types/manage/page', $edit, t('Save content type'));
-
-
-
- $this->backdropGet('node/add/page');
- $this->assertPattern('/<input .* id="edit-menu-link-title" .* maxlength="255" .* \/>/', 'Menu link title field has correct maxlength in node add form.');
-
-
- $node_title = $this->randomName();
- $language = LANGUAGE_NONE;
- $edit = array(
- "title" => $node_title,
- "body[$language][0][value]" => $this->randomString(),
- "menu[enabled]" => 0,
- );
- $this->backdropPost('node/add/page', $edit, t('Save'));
- $node = $this->backdropGetNodeByTitle($node_title);
-
- $this->backdropGet('user');
- $this->assertNoLink($node_title);
-
-
- $edit = array(
- 'menu[enabled]' => 1,
- );
- $this->backdropPost('node/' . $node->nid . '/edit', $edit, t('Save'));
-
- $this->backdropGet('user');
- $this->assertNoLink($node_title);
-
-
- $edit = array(
- 'menu[enabled]' => 1,
- 'menu[link_title]' => $node_title,
- 'menu[weight]' => 17,
- );
- $this->backdropPost('node/' . $node->nid . '/edit', $edit, t('Save'));
-
- $this->backdropGet('user');
- $this->assertLink($node_title);
-
- $this->backdropGet('node/' . $node->nid . '/edit');
- $this->assertOptionSelected('edit-menu-weight', 17, 'Menu weight correct in edit form');
-
-
-
- $edit = array(
- 'menu_options[main-menu]' => 0,
- );
- $this->backdropPost('admin/structure/types/manage/page', $edit, t('Save content type'));
- $this->backdropPost('node/' . $node->nid . '/edit', array(), t('Save'));
-
-
- $this->backdropGet('user');
- $this->assertLink($node_title);
-
-
- $edit = array(
- 'menu_options[main-menu]' => 1,
- );
- $this->backdropPost('admin/structure/types/manage/page', $edit, t('Save content type'));
-
-
-
- $this->backdropGet('node/' . $node->nid . '/edit');
- $this->assertPattern('/<input .* id="edit-menu-link-title" .* maxlength="255" .* \/>/', 'Menu link title field has correct maxlength in node edit form.');
-
-
- $edit = array(
- 'menu[enabled]' => FALSE,
- );
- $this->backdropPost('node/' . $node->nid . '/edit', $edit, t('Save'));
-
- $this->backdropGet('user');
- $this->assertNoLink($node_title);
-
-
- $item = array(
- 'link_path' => 'node/' . $node->nid,
- 'link_title' => $this->randomName(16),
- 'menu_name' => 'management',
- );
- menu_link_save($item);
-
-
-
- $this->backdropGet('node/' . $node->nid . '/edit');
- $this->assertText('Provide a menu link', 'Link in not-allowed menu not shown in node edit form.');
-
- $this->backdropPost('node/' . $node->nid . '/edit', $edit, t('Save'));
- $link = menu_link_load($item['mlid']);
- $this->assertTrue($link, 'Link in not-allowed menu still exists after saving node.');
-
-
- $item['menu_name'] = 'main-menu';
- menu_link_save($item);
-
- $child_node = $this->backdropCreateNode(array('type' => 'post'));
-
- $child_item = array(
- 'link_path' => 'node/'. $child_node->nid,
- 'link_title' => $this->randomName(16),
- 'plid' => $item['mlid'],
- );
- menu_link_save($child_item);
-
- $this->backdropGet('node/'. $node->nid .'/edit');
-
-
- $this->assertNoOption('edit-menu-parent', 'main-menu:'. $item['mlid']);
-
- $this->assertNoOption('edit-menu-parent', 'main-menu:'. $child_item['mlid']);
-
- $this->assertNoOption('edit-menu-parent', 'management:0');
- }
- }