summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2013-08-05 02:12:57 -0400
committerDavid Rothstein <drothstein@gmail.com>2013-08-05 02:12:57 -0400
commit68f6a7c857d40cdf53bb344c974b1899f0fd3104 (patch)
tree4cbda0a120918b342c1b6339ddd54be131fb0ea2 /modules
parentf019275be7d960060c682c69d462832fd53e02f2 (diff)
downloadbrdo-68f6a7c857d40cdf53bb344c974b1899f0fd3104.tar.gz
brdo-68f6a7c857d40cdf53bb344c974b1899f0fd3104.tar.bz2
Issue #1975442 by thedavidmeister, dcam: Fixed drupal_render() should always return a string.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/common.test54
-rw-r--r--modules/simpletest/tests/common_test.module8
2 files changed, 62 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 974812636..8694ff32e 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1565,6 +1565,60 @@ class DrupalRenderTestCase extends DrupalWebTestCase {
}
/**
+ * Tests the output drupal_render() for some elementary input values.
+ */
+ function testDrupalRenderBasics() {
+ $types = array(
+ array(
+ 'name' => 'null',
+ 'value' => NULL,
+ 'expected' => '',
+ ),
+ array(
+ 'name' => 'no value',
+ 'expected' => '',
+ ),
+ array(
+ 'name' => 'empty string',
+ 'value' => '',
+ 'expected' => '',
+ ),
+ array(
+ 'name' => 'no access',
+ 'value' => array(
+ '#markup' => 'foo',
+ '#access' => FALSE,
+ ),
+ 'expected' => '',
+ ),
+ array(
+ 'name' => 'previously printed',
+ 'value' => array(
+ '#markup' => 'foo',
+ '#printed' => TRUE,
+ ),
+ 'expected' => '',
+ ),
+ array(
+ 'name' => 'printed in prerender',
+ 'value' => array(
+ '#markup' => 'foo',
+ '#pre_render' => array('common_test_drupal_render_printing_pre_render'),
+ ),
+ 'expected' => '',
+ ),
+ array(
+ 'name' => 'basic renderable array',
+ 'value' => array('#markup' => 'foo'),
+ 'expected' => 'foo',
+ ),
+ );
+ foreach($types as $type) {
+ $this->assertIdentical(drupal_render($type['value']), $type['expected'], '"' . $type['name'] . '" input rendered correctly by drupal_render().');
+ }
+ }
+
+ /**
* Test sorting by weight.
*/
function testDrupalRenderSorting() {
diff --git a/modules/simpletest/tests/common_test.module b/modules/simpletest/tests/common_test.module
index e75b45237..674a49446 100644
--- a/modules/simpletest/tests/common_test.module
+++ b/modules/simpletest/tests/common_test.module
@@ -101,6 +101,14 @@ function common_test_destination() {
}
/**
+ * Applies #printed to an element to help test #pre_render.
+ */
+function common_test_drupal_render_printing_pre_render($elements) {
+ $elements['#printed'] = TRUE;
+ return $elements;
+}
+
+/**
* Implements hook_TYPE_alter().
*/
function common_test_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) {