From 631ea9911cea3eb93e8b27b212e9b38df9453fd6 Mon Sep 17 00:00:00 2001
From: David Meister <thedavidmeister@gmail.com>
Date: Mon, 10 Jun 2013 00:24:51 +1000
Subject: [PATCH] 2012818-13

---
 .../lib/Drupal/system/Tests/Common/RenderTest.php     | 16 ++++++++++++++++
 .../tests/modules/common_test/common_test.module      | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
index 31e4f34..0a0a745 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
@@ -384,4 +384,20 @@ function testDrupalRenderCache() {
     // Restore the previous request method.
     $_SERVER['REQUEST_METHOD'] = $request_method;
   }
+
+  /**
+   * Tests that #type is handled correctly.
+   */
+  function testDrupalRenderType() {
+    // Theme suggestion is not implemented, #markup should be the fallback.
+    // #type is not set, should inherit #type 'markup' #pre_render from
+    // common_test_element_info_alter() and therefore #prefix 'foo'.
+    $table = array(
+      '#theme' => array('suggestionnotimplemented'),
+      '#markup' => 'bar',
+      '#prefixme' => TRUE,
+    );
+    $rendered = drupal_render($table);
+    $this->assertIdentical($rendered, 'foobar');
+  }
 }
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module
index febfd3a..5414489 100644
--- a/core/modules/system/tests/modules/common_test/common_test.module
+++ b/core/modules/system/tests/modules/common_test/common_test.module
@@ -334,3 +334,22 @@ function common_test_js_and_css_querystring() {
 function common_test_cron() {
   throw new Exception(t('Uncaught exception'));
 }
+
+/**
+ * Implements hook_element_info().
+ *
+ * Adds a #prefix to #type 'markup'.
+ */
+function common_test_element_info_alter(&$type) {
+  $type['markup']['#pre_render'] = array('common_test_prefix_renderable_array');
+}
+
+/**
+ * Attempt to add a prefix to the passed renderable array.
+ */
+function common_test_prefix_renderable_array($element) {
+  if (!empty($element['#prefixme'])) {
+    $element['#prefix'] = 'foo';
+  }
+  return $element;
+}
-- 
1.7.11.1

