function RendererPlaceholdersTest::testNonScalarLazybuilderCallbackContext

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testNonScalarLazybuilderCallbackContext()
  2. 10 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testNonScalarLazyBuilderCallbackContext()
  3. 11.x core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::testNonScalarLazyBuilderCallbackContext()

@covers ::render @covers ::doRender

File

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

Class

RendererPlaceholdersTest
@coversDefaultClass \Drupal\Core\Render\Renderer @covers \Drupal\Core\Render\RenderCache @covers \Drupal\Core\Render\PlaceholderingRenderCache @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function testNonScalarLazybuilderCallbackContext() {
    $element = [];
    $element['#lazy_builder'] = [
        '\\Drupal\\Tests\\Core\\Render\\PlaceholdersTest::callback',
        [
            'string' => 'foo',
            'bool' => TRUE,
            'int' => 1337,
            'float' => 3.14,
            'null' => NULL,
            // array is not one of the scalar types.
'array' => [
                'hi!',
            ],
        ],
    ];
    $this->expectException(\AssertionError::class);
    $this->expectExceptionMessage("A #lazy_builder callback's context may only contain scalar values or NULL.");
    $this->renderer
        ->renderRoot($element);
}

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