function RendererPlaceholdersTest::setupThemeManagerForDetails

Same name 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. 10 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 @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;
    });
}

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