function KernelTestBaseTest::testRender

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRender()
  2. 10 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testRender()
  3. 11.x 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);
}

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