You are here

protected function LayoutPluginManagerTest::setUpFilesystem in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php \Drupal\Tests\Core\Layout\LayoutPluginManagerTest::setUpFilesystem()

Sets up the filesystem with YAML files and annotated plugins.

1 call to LayoutPluginManagerTest::setUpFilesystem()
LayoutPluginManagerTest::setUp in core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php

File

core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php, line 301

Class

LayoutPluginManagerTest
@coversDefaultClass \Drupal\Core\Layout\LayoutPluginManager @group Layout

Namespace

Drupal\Tests\Core\Layout

Code

protected function setUpFilesystem() {
  $module_a_provided_layout = <<<'EOS'
module_a_provided_layout:
  label: 1 column layout
  category: 'Columns: 1'
  description: 'A module provided layout'
  theme_hook: onecol
  path: layouts
  library: module_a/onecol
  regions:
    top:
      label: Top region
    bottom:
      label: Bottom region
module_a_derived_layout:
  deriver: \Drupal\Tests\Core\Layout\LayoutDeriver
  invalid_provider: true
EOS;
  $theme_a_provided_layout = <<<'EOS'
theme_a_provided_layout:
  class: '\Drupal\Core\Layout\LayoutDefault'
  label: 2 column layout
  category: 'Columns: 2'
  description: 'A theme provided layout'
  template: twocol
  path: templates
  library: theme_a/twocol
  default_region: right
  regions:
    left:
      label: Left region
    right:
      label: Right region
EOS;
  $plugin_provided_layout = <<<'EOS'
<?php
namespace Drupal\Core\Plugin\Layout;
use Drupal\Core\Layout\LayoutDefault;
/**
 * @Layout(
 *   id = "plugin_provided_layout",
 *   label = @Translation("Layout plugin"),
 *   category = @Translation("Columns: 1"),
 *   description = @Translation("Test layout"),
 *   path = "core/lib/Drupal/Core",
 *   template = "templates/plugin-provided-layout",
 *   regions = {
 *     "main" = {
 *       "label" = @Translation("Main Region", context = "layout_region")
 *     }
 *   }
 * )
 */
class TestLayout extends LayoutDefault {}
EOS;
  vfsStream::setup('root');
  vfsStream::create([
    'modules' => [
      'module_a' => [
        'module_a.layouts.yml' => $module_a_provided_layout,
      ],
    ],
  ]);
  vfsStream::create([
    'themes' => [
      'theme_a' => [
        'theme_a.layouts.yml' => $theme_a_provided_layout,
      ],
    ],
  ]);
  vfsStream::create([
    'core' => [
      'lib' => [
        'Drupal' => [
          'Core' => [
            'Plugin' => [
              'Layout' => [
                'TestLayout.php' => $plugin_provided_layout,
              ],
            ],
          ],
        ],
      ],
    ],
  ]);
}