protected function RendererPlaceholdersTest::assertPlaceholderRenderCache in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::assertPlaceholderRenderCache()
Parameters
false|array $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 557 - 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\RenderCode
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.');
}
}