function RendererPlaceholdersTest::setupThemeManagerForDetails

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::setupThemeManagerForDetails()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::setupThemeManagerForDetails()
  3. 11.x 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
Tests the creation of an element with a child and a sub-child.

File

core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php, line 1154

Class

RendererPlaceholdersTest
@coversDefaultClass \Drupal\Core\Render\Renderer[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache[[api-linebreak]] @covers \Drupal\Core\Render\PlaceholderingRenderCache[[api-linebreak]] @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;
  });
}

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