Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\KernelTests; | |
4 | |
5 /** | |
6 * A trait used in testing for providing a list of modules in a dataProvider. | |
7 */ | |
8 trait FileSystemModuleDiscoveryDataProviderTrait { | |
9 | |
10 /** | |
11 * A data provider that lists every module in core. | |
12 * | |
13 * @return array | |
14 * An array of module names to test. | |
15 */ | |
16 public function coreModuleListDataProvider() { | |
17 $module_dirs = array_keys(iterator_to_array(new \FilesystemIterator(__DIR__ . '/../../../modules/'))); | |
18 $module_names = array_map(function ($path) { | |
19 return str_replace(__DIR__ . '/../../../modules/', '', $path); | |
20 }, $module_dirs); | |
21 $modules_keyed = array_combine($module_names, $module_names); | |
22 | |
23 $data = array_map(function ($module) { | |
24 return [$module]; | |
25 }, $modules_keyed); | |
26 | |
27 return $data; | |
28 } | |
29 | |
30 } |