diff options
Diffstat (limited to 'modules/user/user.test')
-rw-r--r-- | modules/user/user.test | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/user/user.test b/modules/user/user.test index 2cfb45671..2d54f7078 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -1227,6 +1227,56 @@ class UserAutocompleteTestCase extends DrupalWebTestCase { } } + +/** + * Test user-links in secondary menu. + */ +class UserAccountLinksUnitTests extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'User account links', + 'description' => 'Test user-account links.', + 'group' => 'User' + ); + } + + /** + * Test the user login block. + */ + function testSecondaryMenu() { + // Create a regular user. + $user = $this->drupalCreateUser(array()); + + // Log in and get the homepage. + $this->drupalLogin($user); + $this->drupalGet('<front>'); + + // For a logged-in user, expect the secondary menu to have links for "My + // account" and "Log out". + $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), 1, 'My account link is in secondary menu.'); + + $link = $this->xpath('//ul[@id=:menu_id]/li/a[contains(@href, :href) and text()=:text]', array( + ':menu_id' => 'secondary-menu-links', + ':href' => 'user/logout', + ':text' => 'Log out', + )); + $this->assertEqual(count($link), 1, 'Log out link is in secondary menu.'); + + // Log out and get the homepage. + $this->drupalLogout(); + $this->drupalGet('<front>'); + + // For a logged-out user, expect no secondary links. + $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.'); + } +} + /** * Test user blocks. */ |