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. 10 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:

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 75

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/myprofile/myprofile.info.yml' => [
            'type' => 'profile',
        ],
        'profiles/myprofile/modules/myprofile_nested_module/myprofile_nested_module.info.yml' => [],
        'profiles/otherprofile/otherprofile.info.yml' => [
            'type' => 'profile',
        ],
        'core/modules/user/user.info.yml' => [],
        'profiles/otherprofile/modules/otherprofile_nested_module/otherprofile_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']['otherprofile_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.