You are here

public function ThemeTest::testDrupalRenderChildren in Drupal 9

Same name and namespace in other branches
  1. 8 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 131

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\Tests\system\Kernel\Theme

Code

public function testDrupalRenderChildren() {
  $element = [
    '#theme' => 'theme_test_render_element_children',
    'child' => [
      '#markup' => 'Foo',
    ],
  ];
  $this
    ->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', 'drupal_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_render() avoids #theme_wrappers recursion loop when rendering a render element.');
}