function ExtensionDiscoveryTest::populateFilesystemStructure

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php \Drupal\Tests\Core\Extension\ExtensionDiscoveryTest::populateFilesystemStructure()
  2. 8.9.x core/tests/Drupal/Tests/Core/Extension/ExtensionDiscoveryTest.php \Drupal\Tests\Core\Extension\ExtensionDiscoveryTest::populateFilesystemStructure()
  3. 11.x 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: An associative array where each key represents a directory.

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 125

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',
        ],
        'core/themes/test_theme/test_theme.info.yml' => [
            'type' => 'theme',
        ],
        // Override the core instance of the 'test_theme' theme.
'sites/default/themes/test_theme/test_theme.info.yml' => [
            'type' => 'theme',
        ],
        // 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' => [],
        '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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.