1 user.test | UserAccountLinksUnitTests::testAccountMenu() |
Test the user login block.
File
- core/
modules/ user/ tests/ user.test, line 1800 - Tests for user.module.
Class
- UserAccountLinksUnitTests
- Tests user links in the header menu.
Code
function testAccountMenu() {
// Create a regular user.
$user = $this->backdropCreateUser(array());
// Log in and get the homepage.
$this->backdropLogin($user);
$this->backdropGet('<front>');
// For a logged-in user, expect the secondary menu to have links for "My
// account" and "Log out".
$link = $this->xpath('//*[contains(@class, :menu_id)]//a[contains(@href, :href) and text()=:text]', array(
':menu_id' => 'header-menu',
':href' => 'user',
':text' => 'My account',
));
$this->assertEqual(count($link), 1, 'My account link is in secondary menu.');
$link = $this->xpath('//*[contains(@class, :menu_id)]//a[contains(@href, :href) and text()=:text]', array(
':menu_id' => 'header-menu',
':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->backdropLogout();
$this->backdropGet('<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.');
}