View source
<?php
namespace Drupal\Tests\Core\Layout;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Layout\LayoutDefinition;
use Drupal\Tests\UnitTestCase;
class LayoutDefaultTest extends UnitTestCase {
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));
}
public function providerTestBuild() {
$data = [];
$data['right_only'] = [
[
'right' => [
'foo' => 'bar',
],
],
[
'right' => [
'foo' => 'bar',
],
],
];
$data['switched_order'] = [
[
'right' => [
'foo' => 'bar',
],
'left' => [
'foo' => 'baz',
],
],
[
'left' => [
'foo' => 'baz',
],
'right' => [
'foo' => 'bar',
],
],
];
return $data;
}
}