You can set both main and secondary links to a single menu - this needs a test.

Comments

clemens.tolboom’s picture

Status: Active » Needs work
StatusFileSize
new521 bytes

To be continued

frega’s picture

Status: Needs work » Active

Plan of attack:
1. Create a new menu (#TEST293525#)
2. Add item to that menu new menu (#MENUITEM293525#)
3. Use q=admin/build/menu/settings to set #TEST293525# as the primary (main) and secondary menu
4. assert that #MENUITEM293525# shows up accordingly in the pages

clemens.tolboom’s picture

This still does not work ... what is wrong?

  function testMainMenuAsSecondaryMenu() {
    // create new menu
    $this->menu = $this->addCustomMenu();
    
    $this->assertFalse( empty($this->menu['menu_name']), t('Menu name given @m', array( '@t'=> $this->menu['menu_name'])));
    
    // add menu item to front
    $this->addMenuItem(0, '<front>', $this->menu['menu_name']);
    
    $this->drupalGet('admin/build/menu/settings');
    
    $edit = array (
      'menu_default_node_menu' => $this->menu['menu_name'],
      'menu_secondary_menu_source' => $this->menu['menu_name'],
    );
    
    // EDIT : the path below is absolute ... wrong?
    $this->drupalPost("/admin/build/menu/settings", $edit, t('Save configuration'));
  }
lilou’s picture

Status: Active » Needs work
frega’s picture

Status: Needs work » Needs review
StatusFileSize
new3.78 KB

I hope i am actually testing what this issue is about - first test anxiety ... please find the testing patch attached.

please note: I have added a helper method ( addCustomMenuWithoutEnablingBlock() ) that duplicates most of MenuTestCase::addCustomMenu(). If you think this is useful I can rewrite the patch slightly, changing addCustomMenu() so that you can pass on in which region (if any) you want the block with the menu-links to be displayed.

All the best from budapest airport - thanks for an amazing drupalcon.

Patch failed to apply. More information can be found at http://testing.drupal.org/node/13933. If you need help with creating patches please look at http://drupal.org/patch/create

clemens.tolboom’s picture

I was thinking this $this->drupalLogin($this->big_user); too. At least that explains maybe my error.

@frega : I don't understand that helper functions. Why do we need this? We only have to set both main menu and secondary to the same menu. Right? What do you think of my code in #3 plus this drupalLogin ... shouldn't that be enough?

frega’s picture

@clemens: the helper function prevents the block from being displayed automatically ... if it is displayed automatically (i.e. it is in the source of the page) it is more difficult to assert, that the menu links show up when they are assigned to the primary and secondary menu. you know i would have to distinguish between the test menu being displayed in a "block" or in the primary and secondary navigation.
in your patch a few things lack, i think - but i might be very wrong :): for example you need to nest the menus so that we have the effect of the nested item showing up in the secondary menu ...

i am not sure whether we have to take any more action to get my patch "applied" / tested ...

hope you got back safely to the NL - best, fredrik

frega’s picture

Cosmetic patch update, trying to get the DrupalTestbedBot to test the patch. It seems DrupalTestbedBot never tried to apply patch in #5 (http://drupal.org/node/293525#comment-988048).

clemens.tolboom’s picture

I still don't get it :( The code below is afaik the shortest solution ... but the $item1 menu ran before ok and now not. So still not a patch.

What is wrong with this code below?

  function testMainMenuAsSecondaryMenu() {
    $this->drupalLogin($this->big_user);
    
    // preparation : create new menu with two items
    $menu = $this->addCustomMenu();
    $menu_name = $this->menu['menu_name'];

    $item1 = $this->addMenuItem(0, '<front>', $menu_name);
    $item2 = $this->addMenuItem($item1['mlid'], '<front>', $menu_name);
    
    // these titles must be on the front page
    $link_title1 = $item1['link_title'];
    $link_title2 = $item2['link_title'];
    // end preparation

    // Make Main and Secondary point to same menu
    $this->drupalGet('admin/build/menu/settings');
    $edit = array (
      'menu_default_node_menu' => $menu_name,
      'menu_secondary_menu_source' => $menu_name,
    );
    $this->drupalPost("/admin/build/menu/settings", $edit, t('Save configuration'));

    $this->drupalGet("/admin/build/menu/settings");
    $this->assertResponse($response);
    if ($response == 200) {
      $this->assertText(t("The configuration options have been saved."), t('Main and Secondary set to same menu'));
    }
    
    $this->drupalGet("/admin/build/menu/settings");
    $this->assertResponse($response);
    if ($response == 200) {
      $this->assertText($link_title1, t('Main menu item title @t', array( '@t'=>$link_title1)));
      $this->assertText($link_title2, t('Main menu item title @t', array( '@t'=>$link_title2)));
    }
  }
Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

Component: tests » base system
Category: bug » task
Priority: Critical » Normal

Moving this out of the critical bugs queue - see #607038: Meta issue: fix gaps in code coverage.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.