function RendererPlaceholdersTest::assertPlaceholderRenderCache

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()
  3. 10 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()

@internal

Parameters

false|array $cache_keys: The cache keys.

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
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 553

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($cache_keys, array $expected_data) : void {
    if ($cache_keys !== FALSE) {
        $cached = $this->memoryCache
            ->get($cache_keys, CacheableMetadata::createFromRenderArray($expected_data));
        $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.