Mercurial > hg > cmmr2012-drupal-site
comparison core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
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 } |