function RendererTest::testRenderWithThemeArguments

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderWithThemeArguments()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererTest.php \Drupal\Tests\Core\Render\RendererTest::testRenderWithThemeArguments()
  3. 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 775

Class

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

Namespace

Drupal\Tests\Core\Render

Code

public function testRenderWithThemeArguments() : void {
    $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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.