<?php
/**
* 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/account');
$this->assertFieldChecked('edit-links-mlid2-hidden', "The 'My account' link is enabled by default.");
// Disable the 'My account' link.
$edit = array(
'links[mlid:2][hidden]'=> FALSE,
);
$this->drupalPost('admin/structure/menu/manage/account', $edit, t('Save'));
// Get the homepage.
$this->drupalGet('<front>');
// 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',
':href'=> 'user',
':text'=> 'My account',
));
$this->assertEqual(count($link), 0, 'My account link is not in the secondary menu.');
}
?>
It assumes the ID is 2, when it sometimes can be something else in certain environments.