summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r--modules/simpletest/tests/common.test31
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 4a0240002..7e79450ff 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1747,6 +1747,37 @@ class DrupalRenderTestCase extends DrupalWebTestCase {
'@type' => var_export($element['#type'], TRUE),
)));
}
+
+ /**
+ * Tests caching of an empty render item.
+ */
+ function testDrupalRenderCache() {
+ // Force a request via GET.
+ $request_method = $_SERVER['REQUEST_METHOD'];
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ // Create an empty element.
+ $test_element = array(
+ '#cache' => array(
+ 'cid' => 'render_cache_test',
+ ),
+ '#markup' => '',
+ );
+
+ // Render the element and confirm that it goes through the rendering
+ // process (which will set $element['#printed']).
+ $element = $test_element;
+ drupal_render($element);
+ $this->assertTrue(isset($element['#printed']), t('No cache hit'));
+
+ // Render the element again and confirm that it is retrieved from the cache
+ // instead (so $element['#printed'] will not be set).
+ $element = $test_element;
+ drupal_render($element);
+ $this->assertFalse(isset($element['#printed']), t('Cache hit'));
+
+ // Restore the previous request method.
+ $_SERVER['REQUEST_METHOD'] = $request_method;
+ }
}
/**