You are here

protected function ExtensionDiscoveryTest::populateFilesystemStructure in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php \Drupal\Tests\Core\Extension\ExtensionDiscoveryTest::populateFilesystemStructure()

Adds example files to the filesystem structure.

Parameters

array $filesystem_structure:

Return value

string[][] Format: $[$type][$name] = $yml_file E.g. $['module']['system'] = 'system.info.yml'

1 call to ExtensionDiscoveryTest::populateFilesystemStructure()
ExtensionDiscoveryTest::testExtensionDiscoveryVfs in core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php
Tests extension discovery in a virtual filesystem with vfsStream.

File

core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php, line 110

Class

ExtensionDiscoveryTest
Tests discovery of extensions.

Namespace

Drupal\Tests\Core\Extension

Code

protected function populateFilesystemStructure(array &$filesystem_structure) {
  $info_by_file = [
    'core/profiles/standard/standard.info.yml' => [
      'type' => 'profile',
    ],
    'core/profiles/minimal/minimal.info.yml' => [
      'type' => 'profile',
    ],
    // Override the core instance of the 'minimal' profile.
    'sites/default/profiles/minimal/minimal.info.yml' => [
      'type' => 'profile',
    ],
    'profiles/my_profile/my_profile.info.yml' => [
      'type' => 'profile',
    ],
    'profiles/my_profile/modules/my_profile_nested_module/my_profile_nested_module.info.yml' => [],
    'profiles/other_profile/other_profile.info.yml' => [
      'type' => 'profile',
    ],
    'core/modules/user/user.info.yml' => [],
    'profiles/other_profile/modules/other_profile_nested_module/other_profile_nested_module.info.yml' => [],
    'core/modules/system/system.info.yml' => [],
    'core/themes/seven/seven.info.yml' => [
      'type' => 'theme',
    ],
    // Override the core instance of the 'seven' theme.
    'sites/default/themes/seven/seven.info.yml' => [
      'type' => 'theme',
    ],
    'modules/devel/devel.info.yml' => [],
    'modules/poorly_placed_theme/poorly_placed_theme.info.yml' => [
      'type' => 'theme',
    ],
    'core/themes/engines/twig/twig.info.yml' => [
      'type' => 'theme_engine',
    ],
  ];
  $files_by_type_and_name_expected = [];
  $content_by_file = [];
  foreach ($info_by_file as $file => $info) {
    $name = basename($file, '.info.yml');
    $info += [
      'type' => 'module',
      'name' => "Name of ({$name})",
      'core' => '8.x',
    ];
    $type = $info['type'];
    $content_by_file[$file] = Yaml::dump($info);
    $files_by_type_and_name_expected[$type][$name] = $file;
  }
  $content_by_file['core/modules/system/system.module'] = '<?php';
  $content_by_file['core/themes/engines/twig/twig.engine'] = '<?php';
  foreach ($content_by_file as $file => $content) {
    $pieces = explode('/', $file);
    $this
      ->addFileToFilesystemStructure($filesystem_structure, $pieces, $content);
  }
  unset($files_by_type_and_name_expected['module']['other_profile_nested_module']);
  return $files_by_type_and_name_expected;
}