@@ -18,6 +18,11 @@ class ModuleResolver
18
18
*/
19
19
const MODULE_WHITELIST = 'MODULE_WHITELIST ' ;
20
20
21
+ /**
22
+ * Environment field name for custom module paths.
23
+ */
24
+ const CUSTOM_MODULE_PATHS = 'CUSTOM_MODULE_PATHS ' ;
25
+
21
26
/**
22
27
* Enabled modules.
23
28
*
@@ -166,15 +171,15 @@ protected function getModuleWhitelist()
166
171
public function getModulesPath ()
167
172
{
168
173
if (isset ($ this ->enabledModulePaths )) {
169
- return $ this ->removeBlacklistModules ( $ this -> enabledModulePaths ) ;
174
+ return $ this ->enabledModulePaths ;
170
175
}
171
176
172
177
$ enabledModules = $ this ->getEnabledModules ();
173
178
$ modulePath = defined ('TESTS_MODULE_PATH ' ) ? TESTS_MODULE_PATH : TESTS_BP ;
174
179
$ allModulePaths = glob ($ modulePath . '*/* ' );
175
180
if (empty ($ enabledModules )) {
176
- $ this ->enabledModulePaths = $ allModulePaths ;
177
- return $ this ->removeBlacklistModules ( $ this -> enabledModulePaths ) ;
181
+ $ this ->enabledModulePaths = $ this -> applyCustomModuleMethods ( $ allModulePaths) ;
182
+ return $ this ->enabledModulePaths ;
178
183
}
179
184
180
185
$ enabledModules = array_merge ($ enabledModules , $ this ->getModuleWhitelist ());
@@ -191,8 +196,8 @@ public function getModulesPath()
191
196
}
192
197
}
193
198
194
- $ this ->enabledModulePaths = $ allModulePaths ;
195
- return $ this ->removeBlacklistModules ( $ this -> enabledModulePaths ) ;
199
+ $ this ->enabledModulePaths = $ this -> applyCustomModuleMethods ( $ allModulePaths) ;
200
+ return $ this ->enabledModulePaths ;
196
201
}
197
202
198
203
/**
@@ -241,11 +246,23 @@ public function sortFilesByModuleSequence(array $files)
241
246
return $ this ->sequenceSorter ->sort ($ files );
242
247
}
243
248
249
+ /**
250
+ * A wrapping method for any custom logic which needs to be applied to the module list
251
+ *
252
+ * @param $modulesPath
253
+ * @return array
254
+ */
255
+ protected function applyCustomModuleMethods (&$ modulesPath )
256
+ {
257
+ $ this ->removeBlacklistModules ($ modulesPath );
258
+ return array_merge ($ modulesPath , $ this ->getCustomModulePaths ());
259
+ }
260
+
244
261
/**
245
262
* Remove blacklist modules from input module paths.
246
263
*
247
264
* @param array &$modulePaths
248
- * @return array
265
+ * @return void
249
266
*/
250
267
protected function removeBlacklistModules (&$ modulePaths )
251
268
{
@@ -254,7 +271,22 @@ protected function removeBlacklistModules(&$modulePaths)
254
271
unset($ modulePaths [$ index ]);
255
272
}
256
273
}
257
- return $ modulePaths ;
274
+ }
275
+
276
+ /**
277
+ * Returns an array of custom module paths defined by the user
278
+ *
279
+ * @return array
280
+ */
281
+ protected function getCustomModulePaths ()
282
+ {
283
+ $ custom_module_paths = getenv (self ::CUSTOM_MODULE_PATHS );
284
+
285
+ if (!$ custom_module_paths ) {
286
+ return [];
287
+ }
288
+
289
+ return array_map ('trim ' , explode (', ' , $ custom_module_paths ));
258
290
}
259
291
260
292
/**
0 commit comments