You are here

public function RenderStackTest::test_processPostRenderCache_recursive in Render cache 7.2

@covers ::processPostRenderCache()

File

tests/src/Cache/RenderStackTest.php, line 605
Contains \Drupal\render_cache\Tests\Cache\RenderStackTest

Class

RenderStackTest
@coversDefaultClass \Drupal\render_cache\Cache\RenderStack @group cache

Namespace

Drupal\render_cache\Tests\Cache

Code

public function test_processPostRenderCache_recursive() {
  $this->renderStack
    ->shouldReceive('collectAttached')
    ->times(4)
    ->andReturnUsing(array(
    $this,
    'helperCollectAttached',
  ));
  $cache_info = array(
    'render_cache_cache_strategy' => \RenderCache::RENDER_CACHE_STRATEGY_DIRECT_RENDER,
  );
  $render = array(
    '#markup' => 'bar',
    '#cache' => array(
      'tags' => array(
        'node:1',
      ),
    ),
    '#attached' => array(
      'library' => array(
        array(
          'contextual',
          'contextual-links',
        ),
      ),
    ),
  );
  $render['#post_render_cache'] = array(
    '\\Drupal\\render_cache\\Tests\\Cache\\RenderStackTest::renderStackPostProcessTest' => array(
      array(
        'bar',
        'baz',
        array(
          'baz',
          'foo',
          FALSE,
          $this->renderStack,
        ),
        $this->renderStack,
      ),
    ),
  );
  $result = array(
    '#markup' => 'foo',
    '#cache' => array(
      'tags' => array(
        'bar',
        'baz',
        'node:1',
      ),
    ),
    '#attached' => array(
      'library' => array(
        array(
          'contextual',
          'contextual-links',
        ),
        array(
          'bar',
          'baz',
        ),
        array(
          'foo',
          'baz',
        ),
        array(
          'bar',
          'foo',
        ),
        array(
          'foo',
          'foo',
        ),
      ),
    ),
  );
  $this->renderStack
    ->processPostRenderCache($render, $cache_info);
  $this
    ->assertEquals($result, $render, 'Render matches when using recursive post render cache.');
}