You are here

public function RenderStackTest::test_render in Render cache 7.2

@covers ::render() @depends test_render_common

File

tests/src/Cache/RenderStackTest.php, line 276
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_render($args) {
  list($storage, $render, $original_render_result, $render_result) = $args;
  $this->renderStack
    ->shouldReceive('collectAttached')
    ->times(4)
    ->andReturnUsing(array(
    $this,
    'helperCollectAttached',
  ));
  $stack = $this->renderStack;
  $this->renderStack
    ->shouldReceive('drupalRender')
    ->with(Mockery::on(function (&$render) use ($stack) {
    $render['#printed'] = TRUE;
    $render['bar']['#printed'] = TRUE;

    // This is called by drupal_render() normally.
    if ($stack
      ->supportsDynamicAssets()) {
      $stack
        ->drupal_process_attached($render);
    }

    // Store and remove recursive storage.
    // for our properties.
    $stack
      ->addRecursionStorage($render);
    return TRUE;
  }))
    ->once()
    ->andReturn('foobar');
  $render['x_render_cache_recursion_storage'] = $storage;
  list($markup, $original) = $this->renderStack
    ->render($render);
  $this
    ->assertEquals('foobar', $markup, 'Markup matches expected rendered data.');
  $this
    ->assertEquals($original_render_result, $original, 'Original render array matches expected rendered data.');
  $this
    ->assertEquals($render_result, $render, 'Render array matches expected rendered data.');
}