3 namespace Drupal\Tests\layout_plugin\Kernel;
5 use Drupal\KernelTests\KernelTestBase;
8 * Tests Layout functionality.
12 class LayoutTest extends KernelTestBase {
17 public static $modules = ['system', 'layout_plugin', 'layout_test'];
20 * The layout plugin manager.
22 * @var \Drupal\layout_plugin\Plugin\Layout\LayoutPluginManagerInterface
24 protected $layoutManager;
29 protected function setUp() {
32 $this->layoutManager = $this->container->get('plugin.manager.layout_plugin');
36 * Test listing the available layouts.
38 public function testLayoutDefinitions() {
44 $this->assertEquals($expected_layouts, array_keys($this->layoutManager->getDefinitions()));
48 * Test rendering a layout.
50 * @dataProvider renderLayoutData
52 public function testRenderLayout($layout_id, $config, $regions, $html) {
53 /** @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout */
54 $layout = $this->layoutManager->createInstance($layout_id, $config);
55 $built = $layout->build($regions);
56 $this->render($built);
57 $this->assertRaw($html);
61 * Data provider for testRenderLayout().
63 public function renderLayoutData() {
65 'layout_test_1col' => [
70 '#markup' => 'This is the top',
73 '#markup' => 'This is the bottom',
78 'layout_test_2col' => [
83 '#markup' => 'This is the left',
86 '#markup' => 'This is the right',
91 'layout_test_plugin' => [
94 'setting_1' => 'Config value'
98 '#markup' => 'Main region',
104 $data['layout_test_1col'][] = <<<'EOD'
105 <div class="layout-example-1col clearfix">
106 <div class="region-top">
109 <div class="region-bottom">
115 $data['layout_test_2col'][] = <<<'EOD'
116 <div class="layout-example-2col clearfix">
117 <div class="region-left">
120 <div class="region-right">
126 $data['layout_test_plugin'][] = <<<'EOD'
127 <div class="layout-test-plugin clearfix">
129 <span class="setting-1-label">Blah: </span>
132 <div class="region-main">