function LayoutDefaultTest::testBuild

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Layout/LayoutDefaultTest.php \Drupal\Tests\Core\Layout\LayoutDefaultTest::testBuild()
  2. 8.9.x 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 21

Class

LayoutDefaultTest
@coversDefaultClass \Drupal\Core\Layout\LayoutDefault[[api-linebreak]] @group Layout

Namespace

Drupal\Tests\Core\Layout

Code

public function testBuild($regions, $expected) : void {
  $definition = new LayoutDefinition([
    'theme_hook' => 'layout',
    'library' => 'core/drupal',
    'regions' => [
      'left' => [
        'label' => 'Left',
      ],
      'right' => [
        'label' => 'Right',
      ],
    ],
  ]);
  $expected += [
    '#in_preview' => FALSE,
    '#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.