function ThemeTest::testDrupalRenderChildren

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testDrupalRenderChildren()
  2. 8.9.x core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testDrupalRenderChildren()
  3. 11.x core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testDrupalRenderChildren()

Tests child element rendering for 'render element' theme hooks.

File

core/modules/system/tests/src/Kernel/Theme/ThemeTest.php, line 132

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\Tests\system\Kernel\Theme

Code

public function testDrupalRenderChildren() : void {
    $element = [
        '#theme' => 'theme_test_render_element_children',
        'child' => [
            '#markup' => 'Foo',
        ],
    ];
    $this->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', "\\Drupal::service('renderer')->render() avoids #theme recursion loop when rendering a render element.");
    $element = [
        '#theme_wrappers' => [
            'theme_test_render_element_children',
        ],
        'child' => [
            '#markup' => 'Foo',
        ],
    ];
    $this->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', "\\Drupal::service('renderer')->render() avoids #theme_wrappers recursion loop when rendering a render element.");
}

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