function RendererPlaceholdersTest::assertPlaceholderRenderCache

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()
  2. 10 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()
  3. 11.x 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[[api-linebreak]] @covers ::doRender[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache::get[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache::set[[api-linebreak]] @covers…
RendererPlaceholdersTest::testCacheableParentWithPostRequest in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@covers ::render[[api-linebreak]] @covers ::doRender[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache::get[[api-linebreak]] @covers ::replacePlaceholders[[api-linebreak]]
RendererPlaceholdersTest::testUncacheableParent in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@covers ::render[[api-linebreak]] @covers ::doRender[[api-linebreak]]

File

core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php, line 560

Class

RendererPlaceholdersTest
@coversDefaultClass \Drupal\Core\Render\Renderer[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache[[api-linebreak]] @covers \Drupal\Core\Render\PlaceholderingRenderCache[[api-linebreak]] @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.');
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.