Upgraded drupal core with security updates
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Layout / LayoutDefaultTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Layout;
4
5 use Drupal\Core\Layout\LayoutDefault;
6 use Drupal\Core\Layout\LayoutDefinition;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Layout\LayoutDefault
11  * @group Layout
12  */
13 class LayoutDefaultTest extends UnitTestCase {
14
15   /**
16    * @covers ::build
17    * @dataProvider providerTestBuild
18    */
19   public function testBuild($regions, $expected) {
20     $definition = new LayoutDefinition([
21       'theme_hook' => 'layout',
22       'library' => 'core/drupal',
23       'regions' => [
24         'left' => [
25           'label' => 'Left',
26         ],
27         'right' => [
28           'label' => 'Right',
29         ],
30       ],
31     ]);
32     $expected += [
33       '#settings' => [],
34       '#layout' => $definition,
35       '#theme' => 'layout',
36       '#attached' => [
37         'library' => [
38           'core/drupal',
39         ],
40       ],
41     ];
42
43     $layout = new LayoutDefault([], '', $definition);
44     $this->assertSame($expected, $layout->build($regions));
45   }
46
47   /**
48    * Provides test data for ::testBuild().
49    */
50   public function providerTestBuild() {
51     $data = [];
52     // Empty regions are not added.
53     $data['right_only'] = [
54       [
55         'right' => [
56           'foo' => 'bar',
57         ],
58       ],
59       [
60         'right' => [
61           'foo' => 'bar',
62         ],
63       ],
64     ];
65     // Regions will be in the order defined by the layout.
66     $data['switched_order'] = [
67       [
68         'right' => [
69           'foo' => 'bar',
70         ],
71         'left' => [
72           'foo' => 'baz',
73         ],
74       ],
75       [
76         'left' => [
77           'foo' => 'baz',
78         ],
79         'right' => [
80           'foo' => 'bar',
81         ],
82       ],
83     ];
84     return $data;
85   }
86
87 }