You are here

protected function RendererPlaceholdersTest::generatePlaceholdersWithChildrenTestElement in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::generatePlaceholdersWithChildrenTestElement()
  2. 10 core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php \Drupal\Tests\Core\Render\RendererPlaceholdersTest::generatePlaceholdersWithChildrenTestElement()

Generates an element with placeholders at 3 levels.

Parameters

array $args_1: The arguments for the placeholder at level 1.

array $args_2: The arguments for the placeholder at level 2.

array $args_3: The arguments for the placeholder at level 3.

Return value

array The generated render array for testing.

1 call to RendererPlaceholdersTest::generatePlaceholdersWithChildrenTestElement()
RendererPlaceholdersTest::testRenderChildrenPlaceholdersDifferentArguments in core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
Create an element with a child and subchild. Each element has the same #lazy_builder callback, but with different contexts. They don't modify markup, only attach additional drupalSettings.

File

core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php, line 1078
Contains \Drupal\Tests\Core\Render\RendererPlaceholdersTest.

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

protected function generatePlaceholdersWithChildrenTestElement(array $args_1, array $args_2, array $args_3) {
  $test_element = [
    '#type' => 'details',
    '#cache' => [
      'keys' => [
        'simpletest',
        'renderer',
        'children_placeholders',
      ],
    ],
    '#title' => 'Parent',
    '#attached' => [
      'drupalSettings' => [
        'foo' => 'bar',
      ],
      'placeholders' => [
        'parent-x-parent' => [
          '#lazy_builder' => [
            __NAMESPACE__ . '\\PlaceholdersTest::callback',
            $args_1,
          ],
        ],
      ],
    ],
  ];
  $test_element['child'] = [
    '#type' => 'details',
    '#attached' => [
      'placeholders' => [
        'child-x-child' => [
          '#lazy_builder' => [
            __NAMESPACE__ . '\\PlaceholdersTest::callback',
            $args_2,
          ],
        ],
      ],
    ],
    '#title' => 'Child',
  ];
  $test_element['child']['subchild'] = [
    '#attached' => [
      'placeholders' => [
        'subchild-x-subchild' => [
          '#lazy_builder' => [
            __NAMESPACE__ . '\\PlaceholdersTest::callback',
            $args_3,
          ],
        ],
      ],
    ],
    '#markup' => 'Subchild',
  ];
  return $test_element;
}