You are here

protected function RendererPlaceholdersTest::assertPlaceholderRenderCache in Drupal 10

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

@internal

Parameters

false|array $cid_parts: The cid parts.

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

array $expected_data: A render array with the expected values.

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 560
Contains \Drupal\Tests\Core\Render\RendererPlaceholdersTest.

Class

RendererPlaceholdersTest
@coversDefaultClass \Drupal\Core\Render\Renderer @covers \Drupal\Core\Render\RenderCache @covers \Drupal\Core\Render\PlaceholderingRenderCache @group Render

Namespace

Drupal\Tests\Core\Render

Code

protected function assertPlaceholderRenderCache($cid_parts, array $bubbled_cache_contexts, array $expected_data) : void {
  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.');
  }
}