You are here

public function KernelTestBaseTest::testRender in Zircon Profile 8

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

@covers ::render

File

core/tests/Drupal/KernelTests/KernelTestBaseTest.php, line 168
Contains \Drupal\KernelTests\KernelTestBaseTest.

Class

KernelTestBaseTest
@coversDefaultClass \Drupal\KernelTests\KernelTestBase @group PHPUnit

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(array(
    'filter',
  ));
  $this
    ->assertNotSame($element_info, $this->container
    ->get('element_info'));
  $this
    ->assertNotEmpty($this->container
    ->get('element_info')
    ->getInfo($type));
  $build = array(
    '#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['#children']);
  $this
    ->assertEquals($expected, $output);
}