You are here

public function KernelTestBaseTest::testRender in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRender()
  2. 9 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRender()

@covers ::render

File

core/tests/Drupal/KernelTests/KernelTestBaseTest.php, line 191

Class

KernelTestBaseTest
@coversDefaultClass \Drupal\KernelTests\KernelTestBase

Namespace

Drupal\KernelTests

Code

public function testRender() {
  $type = 'processed_text';
  $element_info = $this->container
    ->get('element_info');
  $this
    ->assertSame([
    '#defaults_loaded' => TRUE,
  ], $element_info
    ->getInfo($type));
  $this
    ->enableModules([
    'filter',
  ]);
  $this
    ->assertNotSame($element_info, $this->container
    ->get('element_info'));
  $this
    ->assertNotEmpty($this->container
    ->get('element_info')
    ->getInfo($type));
  $build = [
    '#type' => 'html_tag',
    '#tag' => 'h3',
    '#value' => 'Inner',
  ];
  $expected = "<h3>Inner</h3>\n";
  $this
    ->assertEquals('core', \Drupal::theme()
    ->getActiveTheme()
    ->getName());
  $output = \Drupal::service('renderer')
    ->renderRoot($build);
  $this
    ->assertEquals('core', \Drupal::theme()
    ->getActiveTheme()
    ->getName());
  $this
    ->assertEquals($expected, $build['#markup']);
  $this
    ->assertEquals($expected, $output);
}