diff --git a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php
index 327a354..21f2065 100644
--- a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php
+++ b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php
@@ -127,6 +127,24 @@ public function testCacheTags() {
     ];
     sort($expected_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_cache_tags);
+
+    // Build a render array with the entity in a sub-element so that lazy
+    // builder elements bubble up outside of the entity and we can check that
+    // it got the correct cache max age.
+    $build = ['#type' => 'container'];
+    $build['entity'] = \Drupal::entityManager()
+      ->getViewBuilder('entity_test')
+      ->view($commented_entity);
+    $renderer->renderRoot($build);
+
+    // The entity itself was cached but the top-level element is max-age 0 due
+    // to the bubbled up max age due to the lazy-built comment form.
+    $this->assertIdentical(Cache::PERMANENT, $build['entity']['#cache']['max-age']);
+    $this->assertIdentical(0, $build['#cache']['max-age'], 'Top level render array has max-age 0');
+
+    // The children (fields) of the entity render array are only built in case
+    // of a cache miss.
+    $this->assertFalse(isset($build['entity']['comment']), 'Cache hit');
   }
 
 }
