function RendererTest::testRenderCacheMaxAge
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderCacheMaxAge()
- 8.9.x core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderCacheMaxAge()
- 10 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderCacheMaxAge()
@covers ::render @covers ::doRender @covers \Drupal\Core\Render\RenderCache::get @covers \Drupal\Core\Render\RenderCache::set
@dataProvider providerTestRenderCacheMaxAge
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ RendererTest.php, line 883
Class
- RendererTest
- @coversDefaultClass \Drupal\Core\Render\Renderer @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testRenderCacheMaxAge($max_age, $is_render_cached, $render_cache_item_expire) : void {
$this->setUpRequest();
$this->setUpMemoryCache();
$element = [
'#cache' => [
'keys' => [
'render_cache_test',
],
'max-age' => $max_age,
],
'#markup' => '',
];
$this->renderer
->renderRoot($element);
$cache_item = $this->cacheFactory
->get('render')
->get([
'render_cache_test',
], CacheableMetadata::createFromRenderArray($element));
if (!$is_render_cached) {
$this->assertFalse($cache_item);
}
else {
$this->assertNotFalse($cache_item);
$this->assertSame($render_cache_item_expire, $cache_item->expire);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.