// Verify that the 'My account' link exists before we check for its
// disappearance.
$this->
assertSession()->
elementsCount('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]', 1
);
// Verify that the 'My account' link is enabled. Do not assume the value of
// auto-increment is 1. Use XPath to obtain input element id and name using
// the consistent label text.
$this->
drupalGet('admin/structure/menu/manage/account'
);
$label =
$this->
xpath('//label[contains(.,:text)]/@for',
[':text' => 'Enable My account menu link'
]);
$this->
assertSession()->
checkboxChecked($label[0
]->
getText());
// Disable the 'My account' link.
$edit['links[menu_plugin_id:user.page][enabled]'
] = FALSE;
$this->
drupalGet('admin/structure/menu/manage/account'
);
$this->
submitForm($edit, 'Save'
);
// Get the homepage.
$this->
drupalGet('<front>'
);
// Verify that the 'My account' link does not appear when disabled.
$this->
assertSession()->
elementNotExists('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]'
);
}