You are here

public function RenderStackTest::test_processPostRenderCache in Render cache 7.2

@covers ::processPostRenderCache()

File

tests/src/Cache/RenderStackTest.php, line 554
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() {
  $this->renderStack
    ->shouldReceive('collectAttached')
    ->twice()
    ->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',
        FALSE,
        $this->renderStack,
      ),
    ),
  );
  $result = array(
    '#markup' => 'baz',
    '#cache' => array(
      'tags' => array(
        'bar',
        'node:1',
      ),
    ),
    '#attached' => array(
      'library' => array(
        array(
          'contextual',
          'contextual-links',
        ),
        array(
          'bar',
          'baz',
        ),
        array(
          'foo',
          'baz',
        ),
      ),
    ),
  );
  $this->renderStack
    ->processPostRenderCache($render, $cache_info, 'Render matches when using normal post render cache.');
  $this
    ->assertEquals($result, $render);
}