You are here

protected function ComponentsKernelTestBase::render in Components! 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Kernel/ComponentsKernelTestBase.php \Drupal\Tests\components\Kernel\ComponentsKernelTestBase::render()

We override KernelTestBase::render() so that it outputs Twig debug comments only for the render array given in a test and not for an entire page.

Throws

\Exception

Overrides KernelTestBase::render

4 calls to ComponentsKernelTestBase::render()
TwigExtensionTest::testAddFilter in tests/src/Kernel/TwigExtensionTest.php
Ensures the Twig "add" filter works inside a Drupal instance.
TwigExtensionTest::testRecursiveMergeFilter in tests/src/Kernel/TwigExtensionTest.php
Ensures the Twig "recursive_merge" filter works inside a Drupal instance.
TwigExtensionTest::testSetFilter in tests/src/Kernel/TwigExtensionTest.php
Ensures the Twig "set" filter works inside a Drupal instance.
TwigExtensionTest::testTemplateFunction in tests/src/Kernel/TwigExtensionTest.php
Ensures the Twig template() function works inside a Drupal instance.

File

tests/src/Kernel/ComponentsKernelTestBase.php, line 32

Class

ComponentsKernelTestBase
Defines a base class for Components kernel testing.

Namespace

Drupal\Tests\components\Kernel

Code

protected function render(array &$elements) : string {

  // \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.');
  }
  return $this->container
    ->get('renderer')
    ->renderRoot($elements);
}