From 1ddc8d96c791fd7a2af5d36fc76a362c80fa44f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"J.=20Rene=CC=81e=20Beach"?= <splendidnoise@gmail.com>
Date: Tue, 18 Dec 2012 13:19:07 -0500
Subject: [PATCH] setup: block context links fix
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


Signed-off-by: J. Renée Beach <splendidnoise@gmail.com>
---
 core/modules/block/block.module                    |    3 ++
 .../contextual/Tests/ContextualLinksTest.php       |   55 ++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 core/modules/contextual/lib/Drupal/contextual/Tests/ContextualLinksTest.php

diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 26bcb25..344ffe7 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -946,6 +946,9 @@ function _block_get_renderable_block($element) {
 
     // Add the content renderable array to the main element.
     $element['content'] = $block->content;
+    if (isset($block->content['#contextual_links'])) {
+      $element['#contextual_links'] = $block->content['#contextual_links'];
+    }
     unset($block->content);
     $element['#block'] = $block;
   }
diff --git a/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualLinksTest.php b/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualLinksTest.php
new file mode 100644
index 0000000..0b9a3e8
--- /dev/null
+++ b/core/modules/contextual/lib/Drupal/contextual/Tests/ContextualLinksTest.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\contextual\Tests\ContextualLinksTest.
+ */
+
+namespace Drupal\contextual\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests to ensure that contextual links in blocks show up as desired.
+ */
+class ContextualLinksTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = array('contextual', 'menu', 'block');
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Contextual link tests',
+      'description' => 'Tests if contextual links in blocks are rendered on the page.',
+      'group' => 'Contextual',
+    );
+  }
+
+  public function setUp() {
+    parent::setUp();
+    $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'administer blocks', 'administer menu'));
+    $this->drupalLogin($web_user);
+  }
+
+  /**
+   * Tests contextual links on Navigation Menu with different users.
+   */
+  public function testNavigationBlock() {
+    // Place the main menu in the sidebar first region.
+    $edit = array('regions[stark]' => 'sidebar_first');
+    $this->drupalPost('admin/structure/block/manage/system/menu-main/configure', $edit, t('Save block'));
+    // Add a link to the empty main menu.
+    $edit = array('link_title' => 'Home', 'link_path' => '<front>');
+    $this->drupalPost('admin/structure/menu/manage/main/add', $edit, t('Save'));
+
+    // Make sure the block is visible on the front page to the logged in user.
+    $this->drupalGet('node');
+    $this->assertLinkByHref('admin/structure/menu/manage/main/list?destination=node', 0, 'List Links link for main menu is displayed.');
+    $this->assertLinkByHref('admin/structure/menu/manage/main/edit?destination=node', 0, 'Edit menu link for main menu is displayed.');
+    $this->assertLinkByHref('admin/structure/block/manage/system/menu-main/configure', 0, 'Configure block link for main menu is displayed.');
+  }
+}
-- 
1.7.10.4

