function LayoutDefaultTest::testBuild

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php \Drupal\Tests\Core\Layout\LayoutDefaultTest::testBuild()
  2. 10 core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php \Drupal\Tests\Core\Layout\LayoutDefaultTest::testBuild()
  3. 11.x core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php \Drupal\Tests\Core\Layout\LayoutDefaultTest::testBuild()

@covers ::build @dataProvider providerTestBuild

File

core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php, line 19

Class

LayoutDefaultTest
@coversDefaultClass \Drupal\Core\Layout\LayoutDefault @group Layout

Namespace

Drupal\Tests\Core\Layout

Code

public function testBuild($regions, $expected) {
    $definition = new LayoutDefinition([
        'theme_hook' => 'layout',
        'library' => 'core/drupal',
        'regions' => [
            'left' => [
                'label' => 'Left',
            ],
            'right' => [
                'label' => 'Right',
            ],
        ],
    ]);
    $expected += [
        '#settings' => [
            'label' => '',
        ],
        '#layout' => $definition,
        '#theme' => 'layout',
        '#attached' => [
            'library' => [
                'core/drupal',
            ],
        ],
    ];
    $layout = new LayoutDefault([], '', $definition);
    $this->assertSame($expected, $layout->build($regions));
}

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