You are here

public function RendererTest::testRenderCacheMaxAge in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderCacheMaxAge()
  2. 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 @covers \Drupal\Core\Render\RenderCache::createCacheID

@dataProvider providerTestRenderCacheMaxAge

File

core/tests/Drupal/Tests/Core/Render/RendererTest.php, line 853
Contains \Drupal\Tests\Core\Render\RendererTest.

Class

RendererTest
@coversDefaultClass \Drupal\Core\Render\Renderer @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function testRenderCacheMaxAge($max_age, $is_render_cached, $render_cache_item_expire) {
  $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:en:stark');
  if (!$is_render_cached) {
    $this
      ->assertFalse($cache_item);
  }
  else {
    $this
      ->assertNotFalse($cache_item);
    $this
      ->assertSame($render_cache_item_expire, $cache_item->expire);
  }
}