setupMemoryCache example

    // bubbling behavior.     $this->rendererConfig['required_cache_contexts'] = [];

    parent::setUp();
  }

  /** * Tests bubbling of assets when NOT using #pre_render callbacks. */
  public function testBubblingWithoutPreRender() {
    $this->setUpRequest();
    $this->setupMemoryCache();

    $this->cacheContextsManager->expects($this->any())
      ->method('convertTokensToKeys')
      ->willReturnArgument(0);

    // Create an element with a child and subchild. Each element loads a     // different library using #attached.     $element = [
      '#type' => 'container',
      '#cache' => [
        'keys' => ['test', 'renderer', 'children_attached'],
      ],
/** * @covers ::render * @covers ::doRender * @covers \Drupal\Core\Render\RenderCache::get * @covers \Drupal\Core\Render\RenderCache::set * @covers \Drupal\Core\Render\RenderCache::createCacheID * * @dataProvider providerRenderCache */
  public function testRenderCache($child_access$expected_tags) {
    $this->setUpRequest();
    $this->setupMemoryCache();

    // Create an empty element.     $test_element = [
      '#cache' => [
        'keys' => ['render_cache_test'],
        'tags' => ['render_cache_tag'],
      ],
      '#markup' => '',
      'child' => [
        '#access' => $child_access,
        '#cache' => [
          

  }

  /** * @covers ::render * @covers ::doRender * * @dataProvider providerPlaceholders */
  public function testUncacheableParent($element$args, array $expected_placeholder_render_array$placeholder_cid_parts, array $bubbled_cache_contexts, array $bubbled_cache_tags, array $placeholder_expected_render_cache_array) {
    if ($placeholder_cid_parts) {
      $this->setupMemoryCache();
    }
    else {
      $this->setUpUnusedCache();
    }

    $this->setUpRequest('GET');

    // No #cache on parent element.     $element['#prefix'] = '<p>#cache disabled</p>';
    $output = $this->renderer->renderRoot($element);
    $this->assertSame('<p>#cache disabled</p><p>This is a rendered placeholder!</p>', (string) $output, 'Output is overridden.');
    
protected function setUp(): void {
    $this->rendererConfig['debug'] = TRUE;

    parent::setUp();
  }

  /** * Test render debug output. */
  public function testDebugOutput() {
    $this->setUpRequest();
    $this->setupMemoryCache();

    $element = [
      '#cache' => [
        'keys' => ['render_cache_test_key'],
        'tags' => ['render_cache_test_tag', 'render_cache_test_tag1'],
        'max-age' => 10,
      ],
      '#markup' => 'Test 1',
    ];
    $markup = $this->renderer->renderRoot($element);

    
Home | Imprint | This part of the site doesn't use cookies.