trait FileSystemModuleDiscoveryDataProviderTrait
Same name in other branches
- 9 core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait
- 8.9.x core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait
- 11.x core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait
A trait used in testing for providing a list of modules in a dataProvider.
Hierarchy
- trait \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait
15 files declare their use of FileSystemModuleDiscoveryDataProviderTrait
- AutoconfigurationTest.php in core/
tests/ Drupal/ KernelTests/ Core/ DependencyInjection/ AutoconfigurationTest.php - AutowireTest.php in core/
tests/ Drupal/ KernelTests/ Core/ DependencyInjection/ AutowireTest.php - DefaultConfigTest.php in core/
tests/ Drupal/ KernelTests/ Config/ DefaultConfigTest.php - DestinationCategoryTest.php in core/
modules/ migrate_drupal/ tests/ src/ Kernel/ Plugin/ migrate/ DestinationCategoryTest.php - GenericTestExistsTest.php in core/
tests/ Drupal/ Tests/ Core/ Extension/ GenericTestExistsTest.php
File
-
core/
tests/ Drupal/ KernelTests/ FileSystemModuleDiscoveryDataProviderTrait.php, line 10
Namespace
Drupal\KernelTestsView source
trait FileSystemModuleDiscoveryDataProviderTrait {
/**
* A data provider that lists every module in core.
*
* @return array
* An array of module names to test.
*/
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;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider | public static | function | A data provider that lists every module in core. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.