function LayoutTest::renderLayoutData

Same name in other branches
  1. 8.9.x core/modules/layout_discovery/tests/src/Kernel/LayoutTest.php \Drupal\Tests\layout_discovery\Kernel\LayoutTest::renderLayoutData()
  2. 10 core/modules/layout_discovery/tests/src/Kernel/LayoutTest.php \Drupal\Tests\layout_discovery\Kernel\LayoutTest::renderLayoutData()
  3. 11.x core/modules/layout_discovery/tests/src/Kernel/LayoutTest.php \Drupal\Tests\layout_discovery\Kernel\LayoutTest::renderLayoutData()

Data provider for testRenderLayout().

File

core/modules/layout_discovery/tests/src/Kernel/LayoutTest.php, line 93

Class

LayoutTest
Tests Layout functionality.

Namespace

Drupal\Tests\layout_discovery\Kernel

Code

public function renderLayoutData() {
    $html = [];
    $html[] = '<div data-drupal-selector="edit-layout" class="layout layout--onecol">';
    $html[] = '<div data-drupal-selector="edit-content" class="layout__region layout__region--content">';
    $html[] = 'This is the content';
    $html[] = '</div>';
    $html[] = '</div>';
    $data['layout_onecol'] = [
        'layout_onecol',
        [],
        [
            'content' => [
                '#markup' => 'This is the content',
            ],
        ],
        $html,
    ];
    $html = [];
    $html[] = '<div data-drupal-selector="edit-layout" class="layout-example-1col clearfix">';
    $html[] = '<div data-drupal-selector="edit-top" class="region-top">';
    $html[] = 'This string added by #process.';
    $html[] = '</div>';
    $html[] = '<div data-drupal-selector="edit-bottom" class="region-bottom">';
    $html[] = 'This is the bottom';
    $html[] = '</div>';
    $html[] = '</div>';
    $data['layout_test_1col_with_form'] = [
        'layout_test_1col',
        [],
        [
            'top' => [
                '#process' => [
                    [
                        static::class,
                        'processCallback',
                    ],
                ],
            ],
            'bottom' => [
                '#markup' => 'This is the bottom',
            ],
        ],
        $html,
    ];
    $html = [];
    $html[] = '<div data-drupal-selector="edit-layout" class="layout-example-1col clearfix">';
    $html[] = '<div data-drupal-selector="edit-top" class="region-top">';
    $html[] = 'This is the top';
    $html[] = '</div>';
    $html[] = '<div data-drupal-selector="edit-bottom" class="region-bottom">';
    $html[] = 'This is the bottom';
    $html[] = '</div>';
    $html[] = '</div>';
    $data['layout_test_1col'] = [
        'layout_test_1col',
        [],
        [
            'top' => [
                '#markup' => 'This is the top',
            ],
            'bottom' => [
                '#markup' => 'This is the bottom',
            ],
        ],
        $html,
    ];
    $html = [];
    $html[] = '<div data-drupal-selector="edit-layout" class="layout layout--layout-test-1col-no-template">';
    $html[] = '<div data-drupal-selector="edit-top" class="layout__region layout__region--top">';
    $html[] = 'This is the top';
    $html[] = '</div>';
    $html[] = '<div data-drupal-selector="edit-bottom" class="layout__region layout__region--bottom">';
    $html[] = 'This is the bottom';
    $html[] = '</div>';
    $html[] = '</div>';
    $data['layout_test_1col_no_template'] = [
        'layout_test_1col_no_template',
        [],
        [
            'top' => [
                '#markup' => 'This is the top',
            ],
            'bottom' => [
                '#markup' => 'This is the bottom',
            ],
        ],
        $html,
    ];
    $html = [];
    $html[] = '<div data-drupal-selector="edit-layout" class="layout-example-2col clearfix">';
    $html[] = '<div data-drupal-selector="edit-left" class="class-added-by-preprocess region-left">';
    $html[] = 'This is the left';
    $html[] = '</div>';
    $html[] = '<div data-drupal-selector="edit-right" class="region-right">';
    $html[] = 'This is the right';
    $html[] = '</div>';
    $html[] = '</div>';
    $data['layout_test_2col'] = [
        'layout_test_2col',
        [],
        [
            'left' => [
                '#markup' => 'This is the left',
            ],
            'right' => [
                '#markup' => 'This is the right',
            ],
        ],
        $html,
    ];
    $html = [];
    $html[] = '<div data-drupal-selector="edit-layout" class="layout-test-plugin clearfix">';
    $html[] = '<div>';
    $html[] = '<span class="setting-1-label">Blah: </span>';
    $html[] = 'Config value';
    $html[] = '</div>';
    $html[] = '<div data-drupal-selector="edit-main" class="region-main">';
    $html[] = 'Main region';
    $html[] = '</div>';
    $html[] = '</div>';
    $data['layout_test_plugin'] = [
        'layout_test_plugin',
        [
            'setting_1' => 'Config value',
        ],
        [
            'main' => [
                '#markup' => 'Main region',
            ],
        ],
        $html,
    ];
    return $data;
}

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