@@ -40,20 +40,19 @@ class ModuleResolver
40
40
const REGISTRAR_CLASS = "\Magento\Framework\Component\ComponentRegistrar " ;
41
41
42
42
/**
43
- * Vendor code path
43
+ * const for vendor
44
44
*/
45
- const VENDOR_CODE_PATH = DIRECTORY_SEPARATOR . " vendor " ;
45
+ const VENDOR = ' vendor ' ;
46
46
47
47
/**
48
- * App code path
48
+ * const for app/code
49
49
*/
50
- const APP_CODE_PATH = DIRECTORY_SEPARATOR . " app " . DIRECTORY_SEPARATOR . "code " ;
50
+ const APP_CODE = ' app ' . DIRECTORY_SEPARATOR . "code " ;
51
51
52
52
/**
53
- * Dev test code path
53
+ * const for dev/tests/acceptance/tests/functional
54
54
*/
55
- const DEV_TEST_CODE_PATH = DIRECTORY_SEPARATOR
56
- . 'dev '
55
+ const DEV_TEST = 'dev '
57
56
. DIRECTORY_SEPARATOR
58
57
. 'tests '
59
58
. DIRECTORY_SEPARATOR
@@ -63,6 +62,21 @@ class ModuleResolver
63
62
. DIRECTORY_SEPARATOR
64
63
. 'functional ' ;
65
64
65
+ /**
66
+ * Vendor code path
67
+ */
68
+ const VENDOR_CODE_PATH = DIRECTORY_SEPARATOR . self ::VENDOR ;
69
+
70
+ /**
71
+ * App code path
72
+ */
73
+ const APP_CODE_PATH = DIRECTORY_SEPARATOR . self ::APP_CODE ;
74
+
75
+ /**
76
+ * Dev test code path
77
+ */
78
+ const DEV_TEST_CODE_PATH = DIRECTORY_SEPARATOR . self ::DEV_TEST ;
79
+
66
80
/**
67
81
* Pattern for Mftf directories
68
82
*/
@@ -101,6 +115,21 @@ class ModuleResolver
101
115
*/
102
116
const TEST_MODULE_NAME_REGEX = "~\S+ " . self ::TEST_MODULE_NAME_SUFFIX . "$~ " ;
103
117
118
+ /**
119
+ * Regex to grab vendor name in vendor
120
+ */
121
+ const VENDOR_NAME_REGEX_V = "~.+ \\/ " . self ::VENDOR . "\/(?< " . self ::VENDOR . ">[^\/]+)\/.+~ " ;
122
+
123
+ /**
124
+ * Regex to grab vendor name in app/code
125
+ */
126
+ const VENDOR_NAME_REGEX_A = "~.+ \\/ " . self ::APP_CODE . "\/(?< " . self ::VENDOR . ">[^\/]+)\/.+~ " ;
127
+
128
+ /**
129
+ * Regex to grab vendor name dev/tests
130
+ */
131
+ const VENDOR_NAME_REGEX_D = "~.+ \\/ " . self ::DEV_TEST . "\/(?< " . self ::VENDOR . ">[^\/]+)\/.+~ " ;
132
+
104
133
/**
105
134
* Enabled modules.
106
135
*
@@ -384,12 +413,12 @@ private function aggregateTestModulePaths()
384
413
if ($ newPath ) {
385
414
$ codePathsToPattern [$ modulePath ] = [
386
415
[
387
- 'pattern ' => 'Test ' . DIRECTORY_SEPARATOR . ' Mftf ' ,
416
+ 'pattern ' => '* ' ,
388
417
'level ' => 0
389
418
],
390
419
[
391
- 'pattern ' => '* ' . self :: TEST_MODULE_NAME_SUFFIX ,
392
- 'level ' => 0
420
+ 'pattern ' => 'Test ' . DIRECTORY_SEPARATOR . ' Mftf ' ,
421
+ 'level ' => null
393
422
]
394
423
];
395
424
}
@@ -432,6 +461,8 @@ private function globRelevantPaths($testPath, $pattern, $level)
432
461
$ allComponents = $ this ->getRegisteredModuleList ();
433
462
434
463
foreach ($ relevantPaths as $ codePath ) {
464
+ $ possibleVendorName = $ this ->getPossibleVendorName ($ codePath );
465
+
435
466
// Reduce magento/app/code/Magento/AdminGws/Test/MFTF to magento/app/code/Magento/AdminGws to read symlink
436
467
// Symlinks must be resolved otherwise they will not match Magento's filepath to the module
437
468
if ($ pattern == self ::MFTF_DIR_PATTERN ) {
@@ -441,7 +472,7 @@ private function globRelevantPaths($testPath, $pattern, $level)
441
472
$ codePath = realpath ($ codePath );
442
473
}
443
474
444
- $ mainModName = array_search ($ codePath , $ allComponents ) ?: basename ($ codePath );
475
+ $ mainModName = array_search ($ codePath , $ allComponents ) ?: $ possibleVendorName . ' _ ' . basename ($ codePath );
445
476
446
477
preg_match (self ::INVALID_DEV_TEST_CODE_PATH_REGEX , $ codePath , $ match );
447
478
if (empty ($ match )) {
@@ -820,4 +851,30 @@ private function validateModulePaths($modulePaths)
820
851
}
821
852
}
822
853
}
854
+
855
+ /**
856
+ * Return possible vendor name from a path given
857
+ *
858
+ * @param string $path
859
+ * @return string
860
+ */
861
+ private function getPossibleVendorName ($ path )
862
+ {
863
+ $ possibleVendorName = 'Unknown ' ;
864
+ $ regexs = [
865
+ self ::VENDOR_NAME_REGEX_A ,
866
+ self ::VENDOR_NAME_REGEX_D ,
867
+ self ::VENDOR_NAME_REGEX_V
868
+ ];
869
+
870
+ foreach ($ regexs as $ regex ) {
871
+ $ match = [];
872
+ preg_match ($ regex , $ path , $ match );
873
+ if (isset ($ match [self ::VENDOR ])) {
874
+ $ possibleVendorName = ucfirst ($ match [self ::VENDOR ]);
875
+ return $ possibleVendorName ;
876
+ }
877
+ }
878
+ return $ possibleVendorName ;
879
+ }
823
880
}
0 commit comments