You are here

protected function RendererPlaceholdersTest::setupThemeManagerForDetails in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::setupThemeManagerForDetails()
  2. 9 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::setupThemeManagerForDetails()

Return value

\Drupal\Core\Theme\ThemeManagerInterface|\PHPUnit\Framework\MockObject\Builder\InvocationMocker

1 call to RendererPlaceholdersTest::setupThemeManagerForDetails()
RendererPlaceholdersTest::testRenderChildrenPlaceholdersDifferentArguments in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
Create an element with a child and subchild. Each element has the same #lazy_builder callback, but with different contexts. They don't modify markup, only attach additional drupalSettings.

File

core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php, line 1139
Contains \Drupal\Tests\Core\Render\RendererPlaceholdersTest.

Class

RendererPlaceholdersTest
@coversDefaultClass \Drupal\Core\Render\Renderer @covers \Drupal\Core\Render\RenderCache @covers \Drupal\Core\Render\PlaceholderingRenderCache @group Render

Namespace

Drupal\Tests\Core\Render

Code

protected function setupThemeManagerForDetails() {
  return $this->themeManager
    ->expects($this
    ->any())
    ->method('render')
    ->willReturnCallback(function ($theme, array $vars) {
    $output = <<<'EOS'
<details>
  <summary>{{ title }}</summary>
  <div class="details-wrapper">{{ children }}</div>
</details>
EOS;
    $output = str_replace([
      '{{ title }}',
      '{{ children }}',
    ], [
      $vars['#title'],
      $vars['#children'],
    ], $output);
    return $output;
  });
}