layoutManager = $this->container->get('plugin.manager.layout_plugin'); } /** * Test listing the available layouts. */ public function testLayoutDefinitions() { $expected_layouts = [ 'layout_test_1col', 'layout_test_2col', 'layout_test_plugin', ]; $this->assertEquals($expected_layouts, array_keys($this->layoutManager->getDefinitions())); } /** * Test rendering a layout. * * @dataProvider renderLayoutData */ public function testRenderLayout($layout_id, $config, $regions, $html) { /** @var \Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout */ $layout = $this->layoutManager->createInstance($layout_id, $config); $built = $layout->build($regions); $this->render($built); $this->assertRaw($html); } /** * Data provider for testRenderLayout(). */ public function renderLayoutData() { $data = [ 'layout_test_1col' => [ 'layout_test_1col', [], [ 'top' => [ '#markup' => 'This is the top', ], 'bottom' => [ '#markup' => 'This is the bottom', ], ], ], 'layout_test_2col' => [ 'layout_test_2col', [], [ 'left' => [ '#markup' => 'This is the left', ], 'right' => [ '#markup' => 'This is the right', ], ], ], 'layout_test_plugin' => [ 'layout_test_plugin', [ 'setting_1' => 'Config value' ], [ 'main' => [ '#markup' => 'Main region', ], ] ], ]; $data['layout_test_1col'][] = <<<'EOD'
This is the top
This is the bottom
EOD; $data['layout_test_2col'][] = <<<'EOD'
This is the left
This is the right
EOD; $data['layout_test_plugin'][] = <<<'EOD'
Blah: Config value
Main region
EOD; return $data; } }