You are here

protected function RendererPlaceholdersTest::assertPlaceholderRenderCache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()

Parameters

FALSE|array $cid_parts:

array $expected_data: FALSE if no render cache item is expected, a render array with the expected values if a render cache item is expected.

string[] $bubbled_cache_contexts: Additional cache contexts that were bubbled when the placeholder was rendered.

3 calls to RendererPlaceholdersTest::assertPlaceholderRenderCache()
RendererPlaceholdersTest::testCacheableParent in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@covers ::render @covers ::doRender @covers \Drupal\Core\Render\RenderCache::get @covers \Drupal\Core\Render\RenderCache::set @covers \Drupal\Core\Render\RenderCache::createCacheID
RendererPlaceholdersTest::testCacheableParentWithPostRequest in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@covers ::render @covers ::doRender @covers \Drupal\Core\Render\RenderCache::get @covers ::replacePlaceholders
RendererPlaceholdersTest::testUncacheableParent in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@covers ::render @covers ::doRender

File

core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php, line 554
Contains \Drupal\Tests\Core\Render\RendererPlaceholdersTest.

Class

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

Namespace

Drupal\Tests\Core\Render

Code

protected function assertPlaceholderRenderCache($cid_parts, array $bubbled_cache_contexts, array $expected_data) {
  if ($cid_parts !== FALSE) {
    if ($bubbled_cache_contexts) {

      // Verify render cached placeholder.
      $cached_element = $this->memoryCache
        ->get(implode(':', $cid_parts))->data;
      $expected_redirect_element = [
        '#cache_redirect' => TRUE,
        '#cache' => $expected_data['#cache'] + [
          'keys' => $cid_parts,
          'bin' => 'render',
        ],
      ];
      $this
        ->assertEquals($expected_redirect_element, $cached_element, 'The correct cache redirect exists.');
    }

    // Verify render cached placeholder.
    $cached = $this->memoryCache
      ->get(implode(':', array_merge($cid_parts, $bubbled_cache_contexts)));
    $cached_element = $cached->data;
    $this
      ->assertEquals($expected_data, $cached_element, 'The correct data is cached: the stored #markup and #attached properties are not affected by the placeholder being replaced.');
  }
}