diff --git a/core/modules/user/src/Plugin/Menu/MyAccountMenuLink.php b/core/modules/user/src/Plugin/Menu/MyAccountMenuLink.php index fac261b..0eb46da 100644 --- a/core/modules/user/src/Plugin/Menu/MyAccountMenuLink.php +++ b/core/modules/user/src/Plugin/Menu/MyAccountMenuLink.php @@ -23,7 +23,7 @@ public function isHidden() { // anonymous users should not see it at all. // @todo - re-write this as a link to user.view with dynamic route // parameters to affect access since hidden should not be dynamic. - return (bool) \Drupal::currentUser()->isAnonymous(); + return $this->pluginDefinition['hidden'] || \Drupal::currentUser()->isAnonymous(); } /** diff --git a/core/modules/user/src/Tests/UserAccountLinksTests.php b/core/modules/user/src/Tests/UserAccountLinksTests.php index 5c951fc..ed07028 100644 --- a/core/modules/user/src/Tests/UserAccountLinksTests.php +++ b/core/modules/user/src/Tests/UserAccountLinksTests.php @@ -90,7 +90,7 @@ function testDisabledAccountLink() { // Verify that the 'My account' link exists before we check for its // disappearance. $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array( - ':menu_class' => 'links', + ':menu_class' => 'menu', ':href' => 'user', ':text' => 'My account', )); @@ -104,10 +104,7 @@ function testDisabledAccountLink() { $this->assertFieldChecked((string) $label[0], "The 'My account' link is enabled by default."); // Disable the 'My account' link. - $input = $this->xpath('//input[@id=:field_id]/@name', array(':field_id' => (string)$label[0])); - $edit = array( - (string) $input[0] => FALSE, - ); + $edit['links[menu_plugin_id:user.page][enabled]'] = FALSE; $this->drupalPostForm('admin/structure/menu/manage/account', $edit, t('Save')); // Get the homepage. @@ -115,7 +112,7 @@ function testDisabledAccountLink() { // Verify that the 'My account' link does not appear when disabled. $link = $this->xpath('//ul[@class=:menu_class]/li/a[contains(@href, :href) and text()=:text]', array( - ':menu_class' => 'links', + ':menu_class' => 'menu', ':href' => 'user', ':text' => 'My account', ));