@@ -222,41 +222,59 @@ public function getModulesPath()
222
222
private function aggregateTestModulePaths ()
223
223
{
224
224
$ allModulePaths = [];
225
- $ appCodeTestPaths = [];
226
- $ testModuleCodePaths = [];
227
225
226
+ // TODO update these paths when we switch a composer based pathing
228
227
// Define the Module paths from app/code
229
228
$ appCodePath = dirname (dirname (dirname (PROJECT_ROOT )))
230
229
. DIRECTORY_SEPARATOR
231
230
. 'app ' . DIRECTORY_SEPARATOR
232
- . 'code ' . DIRECTORY_SEPARATOR
233
- . 'Magento ' ;
231
+ . 'code ' . DIRECTORY_SEPARATOR ;
234
232
235
- // Define the Module paths from defualt TESTS_MODULE_PATH
233
+ // Define the Module paths from default TESTS_MODULE_PATH
236
234
$ modulePath = defined ('TESTS_MODULE_PATH ' ) ? TESTS_MODULE_PATH : TESTS_BP ;
237
235
238
- if (file_exists ($ appCodePath )) {
239
- $ appCodeTestPaths = glob ($ appCodePath . '*/*/Test/Acceptance ' );
240
- }
236
+ // Define the Module paths from vendor modules
237
+ $ vendorCodePath = dirname (dirname (dirname (PROJECT_ROOT )))
238
+ . DIRECTORY_SEPARATOR
239
+ . 'vendor ' . DIRECTORY_SEPARATOR ;
240
+
241
+ $ codePathsToPattern = [
242
+ $ appCodePath => '/Test/Acceptance ' ,
243
+ $ modulePath => '' ,
244
+ $ vendorCodePath => '/Test/Acceptance '
245
+ ];
241
246
242
- // Build an associative array of module name to existing module filepaths based on app/code path
243
- foreach ($ appCodeTestPaths as $ appCodePath ) {
244
- $ mainModName = basename (str_replace ('/Test/Acceptance ' , '' , $ appCodePath ));
245
- $ allModulePaths [$ mainModName ][] = $ appCodePath ;
247
+ foreach ($ codePathsToPattern as $ codePath => $ pattern ) {
248
+ $ allModulePaths = array_merge_recursive ($ allModulePaths , $ this ->globRelevantPaths ($ codePath , $ pattern ));
246
249
}
247
250
248
- // TODO IMPROVE THIS TO ONLY GREP RELEVANT .XML FILES
249
- if (file_exists ($ modulePath )) {
250
- $ testModuleCodePaths = glob ($ modulePath . '*/* ' );
251
+ return $ allModulePaths ;
252
+ }
253
+
254
+ /**
255
+ * Function which takes a code path and a pattern and determines if there are any matching subdir paths. Matches
256
+ * are returned as an associative array keyed by basename (the last dir excluding pattern) to an array containing
257
+ * the matching path.
258
+ *
259
+ * @param string $testPath
260
+ * @param string $pattern
261
+ * @return array
262
+ */
263
+ private function globRelevantPaths ($ testPath , $ pattern )
264
+ {
265
+ $ modulePaths = [];
266
+ $ relevantPaths = [];
267
+
268
+ if (file_exists ($ testPath )) {
269
+ $ relevantPaths = glob ($ testPath . '*/* ' . $ pattern );
251
270
}
252
271
253
- // Add to associative array of module name to existing module filepaths based on defined TEST MODULE PATH
254
- foreach ($ testModuleCodePaths as $ modPath ) {
255
- $ modName = basename ($ modPath );
256
- $ allModulePaths [$ modName ][] = $ modPath ;
272
+ foreach ($ relevantPaths as $ codePath ) {
273
+ $ mainModName = basename (trim ($ codePath , $ pattern ));
274
+ $ modulePaths [$ mainModName ][] = $ codePath ;
257
275
}
258
276
259
- return $ allModulePaths ;
277
+ return $ modulePaths ;
260
278
}
261
279
262
280
/**
0 commit comments