function RendererPlaceholdersTest::testNonArrayReturnFromLazyBuilder

Tests that an error is thrown if a lazy builder doesn't return an array.

File

core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php, line 971

Class

RendererPlaceholdersTest
@coversDefaultClass \Drupal\Core\Render\Renderer[[api-linebreak]] @covers \Drupal\Core\Render\RenderCache[[api-linebreak]] @covers \Drupal\Core\Render\PlaceholderingRenderCache[[api-linebreak]] @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function testNonArrayReturnFromLazyBuilder() : void {
  $element = [
    '#lazy_builder' => [
      '\\Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callbackNonArrayReturn',
      [],
    ],
  ];
  $this->expectException('AssertionError');
  $this->expectExceptionMessage("#lazy_builder callbacks must return a valid renderable array, got boolean from \\Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callbackNonArrayReturn");
  $this->renderer
    ->renderRoot($element);
}

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