diff --git a/modules/user/user.test b/modules/user/user.test index b53db07..92af9fa 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -1487,7 +1487,7 @@ class UserAutocompleteTestCase extends DrupalWebTestCase { /** - * Test user-links in secondary menu. + * Tests user links in the secondary menu. */ class UserAccountLinksUnitTests extends DrupalWebTestCase { public static function getInfo() { @@ -1498,6 +1498,10 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp('menu'); + } + /** * Tests the secondary menu. */ @@ -1533,6 +1537,36 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase { $element = $this->xpath('//ul[@id=:menu_id]', array(':menu_id' => 'secondary-menu-links')); $this->assertEqual(count($element), 0, 'No secondary-menu for logged-out users.'); } + + /** + * Tests disabling the 'My account' link. + */ + function testDisabledAccountLink() { + // Create an admin user and log in. + $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer menu'))); + + // Verify that the 'My account' link is enabled. + $this->drupalGet('admin/structure/menu/manage/user-menu'); + $this->assertFieldChecked('edit-mlid2-hidden', "The 'My account' link is enabled by default."); + + // Disable the 'My account' link. + $edit = array( + 'mlid:2[hidden]' => FALSE, + ); + $this->drupalPost('admin/structure/menu/manage/user-menu', $edit, t('Save configuration')); + + // Get the homepage. + $this->drupalGet(''); + + // Verify that the 'My account' link does not appear when disabled. + $link = $this->xpath('//ul[@id=:menu_id]/li/a[contains(@href, :href) and text()=:text]', array( + ':menu_id' => 'secondary-menu-links', + ':href' => 'user', + ':text' => 'My account', + )); + $this->assertEqual(count($link), 0, 'My account link is not in the secondary menu.'); + } + } /**