function UserAccountLinksTest::testSecondaryMenu in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Tests/UserAccountLinksTest.php \Drupal\user\Tests\UserAccountLinksTest::testSecondaryMenu()
Tests the secondary menu.
File
- core/
modules/ user/ src/ Tests/ UserAccountLinksTest.php, line 39 - Contains \Drupal\user\Tests\UserAccountLinksTest.
Class
- UserAccountLinksTest
- Tests user-account links.
Namespace
Drupal\user\TestsCode
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[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
':menu_class' => 'menu',
':href' => 'user',
':text' => 'My account',
));
$this
->assertEqual(count($link), 1, 'My account link is in secondary menu.');
$link = $this
->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
':menu_class' => '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
->drupalLogout();
$this
->drupalGet('<front>');
// For a logged-out user, expect the secondary menu to have a "Log in" link.
$link = $this
->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array(
':menu_class' => 'menu',
':href' => 'user/login',
':text' => 'Log in',
));
$this
->assertEqual(count($link), 1, 'Log in link is in secondary menu.');
}