diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuNavigation.php b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuNavigation.php index c9d4e6b..251620f 100644 --- a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuNavigation.php +++ b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuNavigation.php @@ -102,10 +102,19 @@ public function build() { $links['menu-' . $item['link']['mlid'] . $class] = $l; } } - return array( + // Do not output this entire block if there are no visible/accessible links. + // @todo This is insufficient for the real world. Respect #access. + if (empty($links)) { + return array(); + } + $build = array( '#theme' => 'links', - '#links' => $links + '#links' => $links, ); + if (!empty($configuration['id'])) { + $build['#attributes']['id'] = $configuration['id']; + } + return $build; } } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 9b03b86..06220a0 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -342,9 +342,6 @@ protected function drupalCreateContentType($settings = array()) { /** * Creates a block instance based on default settings. * - * Note: Until this can be done programmatically, the active user account - * must have permission to administer blocks. - * * @param string $plugin_id * The plugin ID of the block type for this block instance. * @param array $values @@ -367,8 +364,7 @@ protected function drupalCreateContentType($settings = array()) { * @return \Drupal\block\Plugin\Core\Entity\Block * The block entity. * - * @todo - * Add support for creating custom block instances. + * @todo Add support for creating custom block instances. */ protected function drupalPlaceBlock($plugin_id, array $values = array(), array $settings = array()) { $values += array( diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAccountLinksTests.php b/core/modules/user/lib/Drupal/user/Tests/UserAccountLinksTests.php index 7190521..e32b910 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserAccountLinksTests.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAccountLinksTests.php @@ -29,6 +29,15 @@ public static function getInfo() { ); } + function setUp() { + parent::setUp(); + $this->block = $this->drupalPlaceBlock('menu_navigation', array('region' => 'account'), array( + 'menu' => 'account', + 'level' => 0, + 'id' => 'secondary-menu', + )); + } + /** * Tests the secondary menu. */ @@ -38,7 +47,7 @@ function testSecondaryMenu() { // Log in and get the homepage. $this->drupalLogin($user); - $this->drupalGet(''); + $this->drupalGet(''); // For a logged-in user, expect the secondary menu to have links for "My // account" and "Log out". @@ -58,11 +67,16 @@ function testSecondaryMenu() { // Log out and get the homepage. $this->drupalLogout(); - $this->drupalGet(''); + $this->drupalGet(''); // For a logged-out user, expect no secondary links. $element = $this->xpath('//ul[@id=:menu_id]', array(':menu_id' => 'secondary-menu')); $this->assertEqual(count($element), 0, 'No secondary-menu for logged-out users.'); + // The wrapping list should not appear either. + $settings = $this->block->get('settings'); + $this->assertNoRaw($settings['id']); + // The entire menu block should not appear either. + $this->assertNoRaw(check_plain($this->block->label())); } /** diff --git a/core/profiles/standard/config/block.block.bartik.primary_navigation.yml b/core/profiles/standard/config/block.block.bartik.primary_navigation.yml index 04c9b85..f26532a 100644 --- a/core/profiles/standard/config/block.block.bartik.primary_navigation.yml +++ b/core/profiles/standard/config/block.block.bartik.primary_navigation.yml @@ -1,24 +1,11 @@ id: bartik.primary_navigation label: 'Primary Navigation' -uuid: fb1697ef-bfcd-45b2-905a-906fda24b439 region: main_menu weight: '' module: menu status: '1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path plugin: menu_navigation settings: menu: main level: '0' subject: 'Menu Navigation' - cache: '-1' diff --git a/core/profiles/standard/config/block.block.bartik.secondary_navigation.yml b/core/profiles/standard/config/block.block.bartik.secondary_navigation.yml index 505e907..1f3b5fc 100644 --- a/core/profiles/standard/config/block.block.bartik.secondary_navigation.yml +++ b/core/profiles/standard/config/block.block.bartik.secondary_navigation.yml @@ -1,24 +1,12 @@ id: bartik.secondary_navigation label: 'Secondary navigation' -uuid: 1ec67be5-c7b2-4769-ba08-8c17ca65f99e region: account weight: '' module: menu status: '1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path plugin: menu_navigation settings: menu: account level: '0' + id: secondary-menu subject: 'Menu Navigation' - cache: '-1'