function KernelTestBase::render

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::render()

Renders a render array.

Parameters

array $elements: The elements to render.

Return value

string The rendered string output (typically HTML).

11 calls to KernelTestBase::render()
BooleanFormatterTest::renderEntityFields in core/modules/field/tests/src/Kernel/Boolean/BooleanFormatterTest.php
Renders fields of a given entity with a given display.
ClassyTest::testClassyTheme in core/themes/classy/tests/src/Kernel/ClassyTest.php
Tests the classy theme.
DisplayApiTest::testFieldEmpty in core/modules/field/tests/src/Kernel/DisplayApiTest.php
Tests that the prepareView() formatter method still fires for empty values.
DisplayApiTest::testFieldItemListView in core/modules/field/tests/src/Kernel/DisplayApiTest.php
Tests the FieldItemListInterface::view() method.
DisplayApiTest::testFieldItemView in core/modules/field/tests/src/Kernel/DisplayApiTest.php
Tests the FieldItemInterface::view() method.

... See full list

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 911

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

protected function render(array &$elements) {
  // \Drupal\Core\Render\BareHtmlPageRenderer::renderBarePage calls out to
  // system_page_attachments() directly.
  if (!\Drupal::moduleHandler()->moduleExists('system')) {
    throw new \Exception(__METHOD__ . ' requires system module to be installed.');
  }
  // Use the bare HTML page renderer to render our links.
  $renderer = $this->container
    ->get('bare_html_page_renderer');
  $response = $renderer->renderBarePage($elements, '', 'maintenance_page');
  // Glean the content from the response object.
  $content = $response->getContent();
  $this->setRawContent($content);
  return $content;
}

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