You are here

public function RendererTest::testRenderWithThemeArguments in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderWithThemeArguments()

@covers ::render @covers ::doRender

File

core/tests/Drupal/Tests/Core/Render/RendererTest.php, line 591
Contains \Drupal\Tests\Core\Render\RendererTest.

Class

RendererTest
@coversDefaultClass \Drupal\Core\Render\Renderer @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function testRenderWithThemeArguments() {
  $element = array(
    '#theme' => 'common_test_foo',
    '#foo' => $this
      ->randomMachineName(),
    '#bar' => $this
      ->randomMachineName(),
  );
  $this->themeManager
    ->expects($this
    ->once())
    ->method('render')
    ->with('common_test_foo', $this->defaultThemeVars + $element)
    ->willReturnCallback(function ($hook, $vars) {
    return $vars['#foo'] . $vars['#bar'];
  });

  // Tests that passing arguments to the theme function works.
  $this
    ->assertEquals($this->renderer
    ->renderRoot($element), $element['#foo'] . $element['#bar'], 'Passing arguments to theme functions works');
}