You are here

public function RendererTest::testRenderWithThemeArguments in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderWithThemeArguments()
  2. 10 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 769
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 = [
    '#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');
}