function FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider()
  2. 8.9.x core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider()
  3. 11.x core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider()

A data provider that lists every module in core.

Return value

array An array of module names to test.

15 calls to FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider()
AutoconfigurationTest::testCoreServiceTags in core/tests/Drupal/KernelTests/Core/DependencyInjection/AutoconfigurationTest.php
Tests that core services do not use tags if autoconfiguration is enabled.
AutowireTest::testCoreControllerAutowiring in core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php
Tests that core controllers are autowired where possible.
AutowireTest::testCoreServiceAliases in core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php
Tests that core services have aliases correctly defined where possible.
DefaultConfigTest::moduleListDataProvider in core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
A data provider that lists every module in core.
DestinationCategoryTest::setUp in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php

... See full list

File

core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php, line 18

Class

FileSystemModuleDiscoveryDataProviderTrait
A trait used in testing for providing a list of modules in a dataProvider.

Namespace

Drupal\KernelTests

Code

public static function coreModuleListDataProvider() : array {
    $prefix = dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'modules';
    $module_dirs = array_keys(iterator_to_array(new \FilesystemIterator($prefix)));
    $module_names = array_map(function ($path) use ($prefix) {
        return str_replace($prefix . DIRECTORY_SEPARATOR, '', $path);
    }, $module_dirs);
    $modules_keyed = array_combine($module_names, $module_names);
    $data = array_map(function ($module) {
        return [
            $module,
        ];
    }, $modules_keyed);
    return $data;
}

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